Background technology
Along with the continuous progress of semiconductor technology, the integration density of VLSI (Very Large-Scale Integrated, VLSI (very large scale integrated circuit)) is increasing considerably.Integrated level on one chip improves constantly, and makes SoC (System on Chip, SOC (system on a chip)) technology be developed and apply.SoC technology be by the repertoire module integration of a system to single chip, thereby realize on one single chip integrated full-order system function, its processor core is also referred to as core.
Be integrated in normally IP (Intellectual Property, the intellecture property) core on SoC chip.These reusable IP kernels comprise flush bonding processor,, the processing member of memory module, interface module and application-oriented customization.IP kernel integrated on SoC can be divided three classes: soft core (Soft IP), refers to the IP kernel that uses RTL (Register Transfer Level, register transfer rank) or higher level to be described; Stone (Hard IP), refers to and has fixing layer structure, and has carried out the IP kernel of the optimization of customization for the application-specific in particular procedure; Curing core (Firm IP) refers to describe but be to provide parameter and supplies designer to carry out the IP kernel of applied customization.
SoC not only integrated number of transistors is many, and due to integrated different types of function and technology, and due to the collaborative work of software and hardware, makes SoC have complicated architecture and logic interfacing.The high integration of SoC also makes the function of SoC very abundant, has improved the effective utilization to area on sheet, has shortened the length of line on sheet, thereby has improved the performance of whole system.
Multinuclear embedded system (MPSoC) is to the further developing of SoC technology, and refers to the SoC with multiple embedded instruction set processors.MPSoC is in conjunction with the feature of SoC technology and multi-core technology.Multi-core technology refers to integrated polycaryon processor core on a chip, to improve the processing power of processor; As identical in multiple processor cores integrated on fruit chip, core asks that status is identical, is called isomorphism polycaryon processor; As processor core difference integrated on fruit chip, there is dividing of primary processor and coprocessor, be called heterogeneous multi-nucleus processor.Existing polycaryon processor core on MPSoC sheet, integrated again different types of software and hardware, has had the advantage of SoC and multinuclear concurrently.On SoC and MPSoC chip, tend to integrated memory, for processor core provides stores service, thus the efficiency of raising processor.
Real time operating system (RTOS) refers to the multiple task operating system that can external event be made and be completed within the time limiting response, it is the important system resource in embedded computer, different from the operating system of general-purpose platform, it is often embedded into target machine hardware device internal operation, general user cannot see its runnable interface, thereby the embedded OS that is otherwise known as.It often adopts microkernel designs, has the feature of real-time, reliability and tailorability, is very suitable for embedded system and requires the application scenario of processing in real time.
Real-time feature has 2 points, and that is exactly that system not only needs to provide logical result of calculation, and its processing time also need to meet certain requirement, such as can not exceed certain closing time etc.Therefore real-time system can be divided into two classes, when a class is strong (Hard Real-Time); An other class is soft (Soft Real-Time) in real time.What is called refers to that final result will be catastrophic if system fails to start or finish in certain closing time to the processing of certain real-time task when strong, even if this just means that but result is logical still meaningless; And in soft real-time system, be an expectation value closing time that Processing tasks starts or finishes, and may not be certain to meet; Even if the processing time has exceeded closing time, be also significant.
And along with start to turn to the direction of multiprocessing core for the research of computer processor, multinuclear embedded system becomes the challenge that operating system is new, task scheduling is main points wherein.How the task in multinuclear embedded system can be carried out to efficient task scheduling under the constraint of guaranteeing real-time, be a current major issue.This also relates to problem how to utilize multiple processor cores simultaneously.And current existing method for scheduling task is often emphasized real-time, but lack deep analysis for how dispatching on multinuclear, thereby can not realize efficient scheduling; Meanwhile, because existing dispatching method needs a comparatively strict assumed condition, therefore in the time that being used, reality is often very restricted.
Summary of the invention
The present invention is intended to overcome prior art defect, and a kind of multinuclear tasks of embedded system Real-Time Scheduling implementation method is provided.
For achieving the above object, the technical solution used in the present invention is:
A kind of multinuclear embedded system real time task scheduling implementation method, comprises the following steps:
S10, sets up the real-time task set T that comprises whole tasks in multinuclear embedded system;
S20, from set of tasks T, selection does not rely on s task creation set B of other tasks; Taking this s task as starting point, set up respectively with task B1, B2 ..., the Task Dependent that Bs is starting point is related to the set L of sequence;
S30, requires from being short to progress line ordering according to completing the time limit all tasks in set of tasks T, forms task sequence U;
S40, processes initial scheduler task: from U, select m the preceding task of sequence, as initial scheduler task;
S50, sets up scheduling sequence, comprising:
S501: if the task quantity in U is less than or equal to m,, using sequence U as scheduling sequence, despatching work completes, and wherein m is the processor check figure of multinuclear embedded system, otherwise execution step S502;
S502: calculate sort in U the deadline of a preceding m task and by the deadline from being short to long sequence formation sequence R, complete time limit requirement if exceed it without any the task deadline, taking dependence as sequentially, for i processor core C
i, from processor core C
ion task T
cicorresponding Task Dependent is related to arrangement set selection task T
cisubsequent tasks in first is not assigned with and task of not affected by Task Dependent relation is assigned to processor core C
ion; If be subject to the impact of Task Dependent relation, distribute according to the sequence relation in R;
Complete time limit requirement if there is the deadline of q task to exceed it, for this q task, complete time limit requirement according to it and carry out, from being short to progress line ordering, then q task being assigned on a front q processor core successively;
S503 transfers to this m task in scheduling sequence K from U;
S504, if still have task in U, repeating step S402~S403, until no longer include task in U, scheduling sequence K is final scheduling sequence.
Further, described step S10 also comprises:
For the each task in T is set up respectively community set, described community set comprises the execution time length of described task and completes the time limit.
Further, described step S10 also comprises:
For the different task of the N in T, set up set factory { (Ti, Tj) }, wherein the execution of task Tj depends on the execution result of task Ti.
Further, step S40 comprises:
If the task quantity in U is less than or equal to m, according to the sequence in U, all tasks in U are assigned on processor core, despatching work completes; Otherwise the m a choosing task is assigned on m processor core, and this m task is transferred in scheduling sequence K from U.
Owing to adopting technique scheme, the present invention has reduced the complicated Real-Time Scheduling theorizing hypothesis, improve the practicality problem causing for constraint condition too much in real-time scheduling process, for the Real-Time Scheduling of multinuclear tasks of embedded system provides the method for more simplifying, thereby improve the efficiency of multinuclear tasks of embedded system Real-Time Scheduling.The present invention compared with prior art, has following good effect:
(1) high efficiency.In multinuclear embedded system, there are multiple processor cores, can process multiple tasks simultaneously.In the present invention, the multiple tasks in set of tasks are carried out to the analysis of dependence, multiple tasks can be distributed smoothly on multiple processor cores, when completing multitask, scheduling, reaches higher dispatching efficiency;
(2) practicality.In the present invention, simplify the multiple constraint condition to task in multinuclear embedded system, under relatively less constraint condition, angle to the analysis of task from actual motion, make the distribution of task can be more flexible, and make dispatching method can meet actual needs, thereby make method provided by the present invention can there is stronger practicality.
Therefore, the present invention is applicable to multinuclear tasks of embedded system Real-Time Scheduling, takes full advantage of multiple processor cores of polycaryon processor, has both accelerated the processing speed of task in multinuclear embedded system, has ensured again the real-time of real-time task.
Embodiment
Below in conjunction with the drawings and specific embodiments, the present invention will be further described, not the restriction to its protection domain.
A kind of multinuclear embedded system real time task scheduling implementation method, the step of this implementation method as Fig. 1 institute not:
S10, sets up the real-time task set T that comprises whole tasks in multinuclear embedded system.
For the whole tasks in multinuclear embedded system, set up the set T of a task, T is made up of the task of the n in system, can be expressed as:
T={T
o,T
1,…,T
n-1};
For example, for the multinuclear embedded system with 15 tasks, its set T is:
T={T
0,T
1,T
2,T
3,T
4,T
s,T
6,T
7,T
8,T
9,T
10,T
11,T
12,T
13,T
14};
For the task Ti in T (0_q<N), set up community set Ai for it, comprise execution time length Ei and complete time limit requirement Di;
For the above-mentioned set T with 15 tasks, the community set Ai of each task is as shown in the table:
For the different task of the N in T, set up set Γ { (Ti, Tj) }, O<i<N, O≤j<N, wherein the execution of task Tj depends on the execution result of task Ti.In the time that the execution of task Tj depends on the execution result of task Ti, the execution of Tj is no earlier than Ti.
For the above-mentioned set T with 15 tasks, set factory is as follows:
Γ={(T
2,T
9),(T
5,T
4),(T
10,T
1),(T
9,T
0),(T
4,T
3),(T
1,T
13),(T
0,T
11),(T
12,T
14),(T
3,T
7),(T
13,T
8),(T
7,T
6)}。
S20, from set of tasks T, selection does not rely on s task creation set B of other tasks; Taking this s task as starting point, set up respectively with task B1, B2 ..., the Task Dependent that Bs is starting point is related to the set L of sequence.
Between each task, exist mutual relationship, at this, wherein said Task Dependent relation is described: Task Dependent relation refers to that the execution of a task need to be taking the successively ordinal relation of execution of task producing as condition that completes of another task.For example,, for task T
1with task T
2if T finishes the work
2a necessary condition be task T
1the result of calculation producing in implementation; If will finish the work T
2, must wait task T
1this result of calculation is provided.Therefore, claim task T
1with task T
2between there is Task Dependent relation, task T
2depend on task T
1.
From T, select not rely on s task of other tasks, B1, B2 ..., Bs, is designated as set B; Taking this s task as starting point, according to set, factory calculates respectively with task B1, B2 ..., the Task Dependent that Bs is starting point is related to arrangement set L, wherein the Task Dependent of Li correspondence taking task Bi as starting point is related to sequence;
For the above-mentioned set T with 15 tasks, the task of not relying on other tasks is:
T
2,T
5,T
lo;
Wherein, T
2be marked as B1, T
5be marked as B2, T
10be marked as B3, corresponding Li is as follows:
Be T for B1
2, L1 is T
2, T
9, T
0, T
11, T
12, T
14;
Be T for B2
5, L2 is T
5, T
4, T
3, T
7, T
6;
Be T for B3
lo, L3 is T
lo, T
1, T
13, T
8.
S30, requires from being short to progress line ordering according to completing the time limit all tasks in set of tasks T, sets up task sequence U.
For the multinuclear embedded system with m processor core, all tasks in T are required from being short to progress line ordering, formation sequence U according to completing the time limit;
For the above-mentioned set T with 15 tasks, and nuclear volume m=4 on polycaryon processor, U is as follows for its sequence:
T
2,T
5,T
10,T
1,T
9,T
4,T
0,T
3,T
11,T
7,T
i2,T
13,T
6,T
8,T
i4
When descending sort, complete the time limit to require little task to come the front end of sequence.
S40, processes initial scheduler task: from U, select m the preceding task of sequence, as initial scheduler task.
For the above-mentioned set T with 15 tasks, therefrom select the task of sequence front 4, the initial task of scheduling is: T
2, T
5, T
lo, T
1;
These 4 tasks are assigned to processor core C
1, processor core C
2, processor core C
3with processor core C
4, corresponding as follows:
Task |
Corresponding processor core |
T
2 |
C
1 |
T
5 |
C
2 |
T
10 |
C
3 |
T
1 |
C
4 |
S50, sets up scheduling sequence, comprising:
S501: if the task quantity in U is less than or equal to m,, using sequence U as scheduling sequence, despatching work completes, and wherein m is the processor check figure of multinuclear embedded system, otherwise execution step S502.
S502: calculate sort in U the deadline of a preceding m task and by the deadline from being short to long sequence formation sequence R, complete time limit requirement if exceed it without any the task deadline, taking dependence as sequentially, for i processor core C
i, from processor core C
ion task T
cicorresponding Task Dependent is related to arrangement set selection task T
cisubsequent tasks in first is not assigned with and task of not affected by Task Dependent relation is assigned to processor core C
ion; If be subject to the impact of Task Dependent relation, distribute according to the sequence relation in R;
Complete time limit requirement if there is the deadline of q task to exceed it, for this q task, complete time limit requirement according to it and carry out, from being short to progress line ordering, then q task being assigned on a front q processor core successively.
S503 transfers to this m task in scheduling sequence K from U;
S504, if still have task in U, repeating step S402~S403, until no longer include task in U, scheduling sequence K is final scheduling sequence.
From U, in remaining 11 tasks, select preceding 4 of sequence, calculate respectively their task deadlines while being assigned on these four processor cores, as shown in the table respectively:
? |
C
1 |
C
2 |
C
3 |
C
4 |
T
o |
14 |
19 |
18 |
16 |
T
4 |
10 |
15 |
14 |
12 |
T
0 |
9 |
14 |
13 |
11 |
T
3 |
7 |
12 |
11 |
9 |
Any distribution of follow-up 4 tasks on 4 processor cores all can not produce any situation that the time limit requires that exceeded.
But owing to being subject to dependence constraint, i.e. T
8depend on T
13, T
13should compare T
8first distribute.Therefore, for processor core C
1, select C
1on task T
2follow-up work T
9be assigned to C
1on; For processor core C
2, select C
2on task T
5follow-up work T
4be assigned to C
2on; For processor core C
3, select C
3on task T
10follow-up work T
8be assigned to C
3on; For processor core C
4, select C
4on task T
1follow-up work T
13be assigned to C
4on.
Task |
Corresponding processor core |
T
0 |
C
1 |
T
4 |
C
2 |
T
13 |
C
3 |
T
8 |
C
4 |
These 4 tasks are removed from U, and now the sequence in U is:
T
0,T
3,T
11,T
7,T
12,T
6,T
14;
And scheduling sequence K is:
T
2,T
5,T
10,T
1,T
9,T
13,T
8,T
4;
T
9, T
4, T
13and T
8starting Executing Time be respectively:
T
9at moment 4, T
4at moment 9, T
8at moment 8, T
13in the moment 6;
The end of run time of 4 tasks is respectively:
T
9at moment 14, T
4at moment 15, T
8at moment 16, T
13in the moment 15;
Sequence R is:
T
9,T
4,T
13,T
8;
Next from U, in follow-up 7 tasks, select preceding 4 of sequence, calculate respectively their task deadlines while being assigned on these four processor cores, as shown in the table respectively:
? |
C
1 |
C
2 |
C
3 |
C
4 |
T
0 |
19 |
20 |
21 |
20 |
T
3 |
26 |
27 |
28 |
27 |
T
11 |
21 |
22 |
23 |
22 |
T
7 |
20 |
21 |
22 |
21 |
In follow-up 4 tasks, T
3may be owing to being assigned to C
2and C
3on cause T
3working time exceeded time limit requirement.For ensureing T
scan meet time limit requirement, adopt following distribution method: for processor core C
1, select T
3be assigned to C
1on; For processor core C
2, select task T
0be assigned to C
2on; For processor core C
3, select task T
11be assigned to C
3on; For processor core C
4, select C
4task T
7be assigned to C
4on.
Task |
Corresponding processor core |
T
3 |
C
1 |
T
0 |
C
2 |
T
11 |
C
3 |
T
7 |
C
4 |
These 4 tasks are removed from U, and now the sequence in U is:
T
12,T
6,T
14;
And scheduling sequence K is:
T
2,T
5,T
10,T
1,T
9,T
13,T
8,T
4,T
3,T
0,T
11,T
7;
T
3, T
0, T
11and T
7starting Executing Time be respectively:
T
3at moment 14, T
0at moment 15, T
11at moment 16, T
7in the moment 15;
The end of run time of 4 tasks is respectively:
T
3at moment 26, T
0at moment 20, T
11at moment 23, T
7in the moment 21;
Sequence R is:
T
0,T
7,T
11,T
3;
Next to 3 tasks in U, calculate respectively their task deadlines while being assigned on these four processor cores, as shown in the table respectively:
? |
C
1 |
C
2 |
C
3 |
C
4 |
T
12 |
34 |
28 |
31 |
29 |
T
6 |
35 |
29 |
32 |
30 |
T
14 |
36 |
30 |
33 |
31 |
Any distribution on 4 processor cores of 3 tasks all can not produce any situation that the time limit requires that exceeded.
But owing to being subject to dependence constraint, i.e. T
14depend on T
12, T
12should compare T
14first distribute.Therefore, for processor core C
1, select C
1on task T
3follow-up work T
6be assigned to C
1on; For processor core C
2, select C
2on task T
0follow-up work T
12be assigned to C
2on; For processor core C
3, select C
3on task T
11follow-up work T
14be assigned to C
3on; For processor core C
4, this processor core free time.
Task |
Corresponding processor core |
T
6 |
C
1 |
T
12 |
C
2 |
T
14 |
C
3 |
These 4 tasks are removed from U, and now the sequence in U is empty.
And final scheduling sequence K is:
T
2,T
5,T
10,T
1,T
9,T
13,T
8,T
4,T
3,T
0,T
11,T
7,T
12,T
6,T
14。
The above is only the preferred embodiment of the present invention; it should be pointed out that for those skilled in the art, under the premise without departing from the principles of the invention; any innovation and creation, amendment that is no more than connotation scope of the present invention, all falls into protection scope of the present invention.