Tải bản đầy đủ (.pdf) (10 trang)

Tài liệu Lịch khai giảng trong các hệ thống thời gian thực P5 doc

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (364.44 KB, 10 trang )

5
Multiprocessor Scheduling
5.1 Introduction
In this chapter, we limit the study to multiprocessor systems with centralized control
that are called ‘strongly coupled systems’. The main characteristics of such systems are
the existence of a common base of time (for global scheduling of events and tasks) and
a common memory (for implementing the vector of communication between tasks).
Consequently, one has a global view of the state of the system accessible at every
moment. In addition to the common memory, which contains the whole of the code
and the data shared by the different tasks, the processors can have local memory (stack,
cache memory, and so on). These systems present strong analogies with the centralized
systems (uniprocessor) while primarily being different by their capacity to implement
parallel execution of tasks. In a multiprocessor environment, a scheduling algorithm
is valid if all task deadlines are met. This definition, identical to the one used in the
uniprocessor context, is extended with the two following conditions:
• a processor can execute only one task at any time;
• a task is treated only by one processor at any time.
The framework of the study presented here is limited to the most common architec-
ture, which is made up of identical processors (identical speed of processing) with
an on-line preemptive scheduling. In this book, we do not treat off-line scheduling
algorithms, which are often very complex, and not suitable for real-time systems. It
is, however, important to note that off-line algorithms are the only algorithms which
make it possible to obtain an optimal schedule (by the resolution of optimization prob-
lems of linear systems) and to handle some configurations unsolved by an on-line
scheduling algorithm.
5.2 First Results and Comparison
with Uniprocessor Scheduling
The first significant result is a theorem stating the absence of optimality of on-line
scheduling algorithms (Sahni, 1979):
Theorem 5.1:
An on-line algorithm which builds a feasible schedule for any set of tasks with


deadlines within m processors (m ≥ 2), cannot exist.
Scheduling in Real-Time Systems.
Francis Cottet, Jo¨elle Delacroix, Claude Kaiser and Zoubir Mammeri
Copyright

2002 John Wiley & Sons, Ltd.
ISBN: 0-470-84766-2
94 5 MULTIPROCESSOR SCHEDULING
From Theorem 5.1, we can deduce that, in general, the centralized-control real-time
scheduling on multiprocessors could not be an optimal scheduling. In the case of a
set of periodic and independent tasks {τ
i
(r
i
,C
i
,D
i
,T
i
), i ∈ [1,n]} to execute on m
processors, a second obvious result is:
Necessary condition:
The necessary condition of schedulability referring to the maximum load U
j
of
each processor j(U
j
≤ 1,j ∈ [1,m]) is:
U =

m

j =1
U
j
=
n

i=1
u
i
=
n

i=1
C
i
P
i
≤ m(5.1)
where u
i
is the processor utilization factor of task
τ
i
.
A third result is related to the schedule length, which is identical to that in the unipro-
cessor environment:
Theorem 5.2:
There is a feasible schedule for a set of periodic and independent tasks if and

only if there is a feasible schedule in the interval [r
min
,r
max
+ ]wherer
min
=
Min{r
i
},r
max
= Max{r
i
}, = LCM {T
i
},andi ∈ [1,n].
LCM(T
i
) means the least common multiple of periods T
i
(i = 1,...,n).Forinstance,
the earliest deadline first algorithm, which is optimal in the uniprocessor case, is
not optimal in the multiprocessor case. To show that, let us consider the following
set of four periodic tasks {τ
1
(r
0
= 0,C = 1,D = 2,T = 10), τ
2
(r

0
= 0,C = 3,D =
3,T = 10), τ
3
(r
0
= 1,C = 2,D = 3,T = 10), τ
4
(r
0
= 2,C = 3,D = 3,T = 10)} to
execute on two processors, Proc
1
and Proc
2
. The EDF schedule does not respect the
deadline of task τ
4
, whereas there are feasible schedules as shown in Figure 5.1b.
(a) Infeasible schedule according to the EDF algorithm

τ
1
τ
3
τ
4
τ
1
τ

3
τ
4
τ
3
τ
2
τ
2
Proc
1

Proc
2

Proc
1

Proc
2


1 0 3 2
t
4 6 5 7
1 0 3 2 4 6 5 7
1 0 3 2 4 6 5 7
1 0 3 2
t
t

t

4 6 5 7
(b) Feasible schedule
Missed deadline
Figure 5.1 Example showing that the EDF algorithm is not optimal in the multiprocessor
environment
5.3 MULTIPROCESSOR SCHEDULING ANOMALIES 95
5.3 Multiprocessor Scheduling Anomalies
It is very important to stress that some applications, which are executed in a multipro-
cessor environment, are prone to anomalies at the time of apparently positive changes
of parameters. Thus, it was proven that (Graham, 1976):
Theorem 5.3:
If a task set is optimally scheduled on a multiprocessor with some priority assign-
ment, a fixed number of processors, fixed execution times, and precedence con-
straints, then increasing the number of processors, reducing computation times, or
weakening the precedence constraints can increase the schedule length.
This results implies that if tasks have deadlines, then adding resources (for instance,
adding processors) or relaxing constraints can make things worse. The following
example can best illustrate why Graham’s theorem is true.
Let us consider a set of six tasks that accept preemption but not migration (i.e.
the tasks cannot migrate from one processor to another during execution). These tasks
have to be executed on two identical processors using a fixed-priority based schedul-
ing algorithm (external priorities of tasks are fixed as indicated by Table 5.1). The
Table 5.1. Set of six tasks to highlight anomalies
of multiprocessor scheduling
Tas k r
i
C
i

d
i
Priority
τ
1
0 5 10 1 (max)
τ
2
0 [2, 6] 10 2
τ
3
4815 3
τ
4
01020 4
τ
5
5 100 200 5
τ
6
7 2 22 6 (min)
Priority
inversion
5010
t
15 20 25
5010
t
15 20 25
C

2
= 2

C
2
= 6

5010
t
15 20 25
5010
t
15 20 25
τ
1
τ
5
τ
2
τ
4
τ
3
τ
1
τ
3
τ
2
τ

4
τ
6
τ
5
τ
4
τ
6
Proc
1

Proc
2

Proc
1

Proc
2

Figure 5.2 Schedules of the task set presented in Table 5.1 considering the bounds of the
computation time of task
τ
2
96 5 MULTIPROCESSOR SCHEDULING
Priority
inversion
5010
t

15 20 25
5010
t
15 20 25
C
2
= 3
C
2
= 5
5010
t
15 20 25
5010
t
15 20 25
τ
1
τ
5
τ
2
τ
4
τ
3
τ
1
τ
3

τ
2
τ
4
τ
6
τ
5
τ
4
τ
6
Proc
1

Proc
2

Proc
1

Proc
2


Missed deadline
Best response time
Figure 5.3 Schedules of the task set presented in Table 5.1 considering two computation times
of task
τ

2
taken inside the fixed interval
computation time of task τ
2
is in the interval [2, 6]. The current analysis in the unipro-
cessor environment consists of testing the schedulability of a task set for the bounds
of the task computation time interval. The results presented in Figure 5.2 show a fea-
sible schedule for each one of the bounds of the computation time interval C
2
with,
however, a phenomenon of priority inversion between tasks τ
4
and τ
5
for the weakest
computation time of task τ
2
.
The schedules, built for two other values of C
2
taken in the fixed interval, show the
anomalies of multiprocessor scheduling (Figure 5.3): an infeasible schedule for C
2
= 3
(missed deadlines for tasks τ
4
and τ
6
), and a feasible schedule for C
2

= 5 with better
performance (lower response time for tasks τ
4
and τ
6
).
5.4 Schedulability Conditions
5.4.1 Static-priority schedulability condition
Here we deal with a static-priority scheduling of systems of n periodic tasks {τ
1
, τ
2
,...,
τ
n
} on m identical processors (m ≥ 2). The assumptions are: task migration is permitted
(at task start or after it has been preempted) and parallelism is forbidden. Without
loss of generality, we assume that T
i
≤ T
i+1
for all i, 1 ≤ i ≤ n;i.e.thetasksare
indexed according to increasing order of periods. Given u
i
the processor utilization of
each task τ
i
, we define the global processor utilization factor U as classically for the
one-processor context.
5.4 SCHEDULABILITY CONDITIONS 97

The priority assignment is done according to the following rule (Andersson et al.,
2001):
• if u
i
>m/(3m − 2) then τ
i
has the highest priority and ties are broken arbitrarily
but in a consistent manner (always the same for the successive instances);
• if u
i
≤ m/(3m − 2) then τ
i
has the RM priority (the smaller the period, the higher
the priority).
With this priority assignment algorithm, we have a sufficient schedulability condition
(Andersson et al., 2001):
Sufficient condition:
A set of periodic and independent tasks with periods equal to deadlines such that
T
i
≥ T
i+1
for i ∈ [1,n− 1] is schedulable on m identical processors if:
U ≤
m
2
3m − 2
(5.2)
Consider an example of a set of five tasks to be scheduled on a platform of three
identical unit-speed processors (m = 3). The temporal parameters of these tasks are:

τ
1
(r
0
= 0,C = 1,D = 7,T = 7), τ
2
(r
0
= 0,C = 2,D = 15,T = 15), τ
3
(r
0
= 0,C =
9,D = 20,T = 20), τ
4
(r
0
= 0,C = 11,D = 24,T = 24), τ
5
(r
0
= 0,C = 2,D = 25,
T = 25). The utilization factors of these five tasks are respectively: 0.143, 0.133, 0.45,
0.458 and 0.08. Following the priority assignment rule, we get:
• u
i
>
m
3m − 2
= 0.4286 for both tasks τ

3
and τ
4
• u
i

m
3m − 2
= 0.4286 for the other tasks τ
1
, τ
2
and τ
5
Hence, tasks τ
3
and τ
4
will be assigned the highest priorities and the remaining three
tasks will be assigned according to RM priorities. The possible priority assignments are
therefore as follows in a decreasing priority order: τ
3
, τ
4
, τ
1
, τ
2
, τ
5

or τ
4
, τ
3
, τ
1
, τ
2
, τ
5
.
In this example, the global processor utilization factor U is equal to 1.264 and it is
smaller than the limit defined above by the sufficient condition: m
2
/(3m − 2) = 1.286.
So we can assert that this task set is schedulable on a platform of three processors.
Figure 5.4 shows a small part of the scheduling period of this task set.
5.4.2 Schedulability condition based on task
period property
In order to be able to obtain schedulability conditions, the multiprocessor scheduling
problem should be restricted. In this case, a particular property of the task period
is used to elaborate a specific sufficient condition. If we consider a set of periodic
and independent tasks with periods equal to deadlines (D
i
= T
i
), we have a sufficient
schedulability condition under the assumption that the previous necessary condition
(i.e. (5.1)) is satisfied (Dertouzos and Mok, 1989; Mok and Dertouzos, 1978):

×