Professional Documents
Culture Documents
Problem formulation
17 17
C (3/20)
sleep(4); sleep(8); sleep(17); 0 3 7 24 26
7 8
3 3 3 3 3 3 3 while (1) {
A (2/5)
if (count%T1 == 0) function1();
0 5 10 15 20 25 30
if (count%T2 == 0) function2();
6 6 6
B (2/8) if (count%T3 == 0) function3();
2 4 12 14 22 24 32 34
count++;
12
C (6/20) if (count == T1*T2*T3) count = 0;
0 4 7 10 14 17 30 34
delay(1); // wait for 1 ms
30 instead of 20 }
9 10
11 12
10/14/2019
}
} 13 14
B (3/10)
1 11 13 16 23 26 31
C (5/20)
0 4 9 12 24
19 20
What do we do during task overruns? If one or more tasks need to be upgraded, we may
have to re-design the whole schedule again.
Let the task continue
– we can have a domino effect on all the other Example: B is updated so that CB = 20 ms
tasks (timeline break) now CA + CB >
Abort the task
– the system can remain in inconsistent states. A B
0 25
25 26
Expandibility Expandibility
CA + CB1
Guarantee:
CA + CB2 + CC minor cycle: = 25 =5 40 sync.
major cycle: T = 100 T = 200 per cycle!
27 28
T Method
1. Assign priorities to each task based on its
0 25 50 75 100 125 150 175 200 timing constraints.
29 30
10/14/2019
1
P2 > P1
2
31 32
RM
1
If a task set is not schedulable by RM,
P1 > P2
then it cannot be scheduled by any fixed 2
priority assignment.
35 36
10/14/2019
37 38
B 1
0 40 80 0 3 6 9 12 15 18
C 2
0 100 0 3 6 9 12 15 18
deadline miss
Note that small parameter variations are automatically
handled by the scheduler without any intervention.
39
2 i 1 Ti
0 3 6 9 12 15 18
Up is a measure of the processor load.
41
10/14/2019
1 1
0 3 6 9 12 15 18
2 2
0 3 6 9 12 15 18
R2
deadline miss
1 1
0 3 6 9 12 15 18
2
2
0 3 6 9 12 15 18 R2
43 44
Idle time
However, there are cases in which Up ≤ 1
but the task set is not schedulable by RM.
i 2/14
3 4
Up 0.944 3 3
6 9 Up 0.833
6 9
1
0 3 6 9 12 15 18 1
0 3 6 9 12 15 18
2
0 3 6 9 12 15 18 2
deadline miss 0 3 6 9 12 15 18
Given this task set (period configuration), what is the NOTE: If C1 or C2 is increased,
higher utilization that guarantees feasibility? 2 will miss its deadline!
47 48
10/14/2019
2 4 2 4
U ub 0.9 Up 1
4 10 4 8
1 1
0 4 8 12 16 0 4 8 12 16
2 2
0 2 4 6 8 10 12 14 16 18 20 0 4 8 12 16
NOTE: The upper bound Uub depends on the NOTE: The upper bound Uub depends on the
specific task set. specific task set.
49 50
Ulub
NOTE
... If Ulub < Up 1 we cannot say anything
about the feasibility of that task set.
51 52
RM
U lub
n 21/ n 1 69%
for n Ulub ln 2
n
53
10/14/2019
2
0 4 8 12 16
U p n 21/ n 1
0 4 8 12 16
56
57 58
C1 C1 C1 C1 T1 C T2
1 Uub = F + 1 –F
T2 T2 T1
2 Uub
FT1 T2
1
T2
C2max = F(T1 – C1) F
T1
C1 F(T1 – C1) T C T2 C1
Uub = + = F 1 + 1 –F T2 FT1 T1
T1 T2 T2 T2 T1
61 62
we can write:
Tn–1 n 1 n 1
Cn
n C n T1 Ck U ub Ri
2
n
0 T1 Tn k 1
i 1
P
65 66
10/14/2019
Hence:
U lub n 21 / n 1
67 68
Ck T1
i 1
Ri
i 1
(U i 1)
i 1
(U i 1) 2
0 T1 Tn k 1
69 70
Scheduling algorithms
Deadline Monotonic: pi 1/Di (static)
Earliest Deadline First: pi 1/di (dynamic)
0.83 1 U2 71 72
10/14/2019
i 1
k Ri
Ri Ci Ck
k 1 Tk
i
0 Ri
Iterative solution:
Interference of k on i Ri
in the interval [0, Ri]:
I ik Ck
Tk Ri0 Ci
iterate while
Interference on i i 1
Ri i 1
Ri( s 1)
by high-priority tasks: Ii Ck Ris Ci Ck Ris Ri( s 1)
k 1 Tk k 1 Tk
75 76
78
10/14/2019
3 4 3 4
Up 0.944 Up 0.944
6 9 6 9
Di = Ti
1 1
0 3 6 9 12 15 18 0 3 6 9 12 15 18
2 2
0 3 6 9 12 15 18 0 3 6 9 12 15 18
deadline miss
79 80
Transforming s in s’
If is not schedulable by EDF, then it
cannot be scheduled by any algorithm. Feasibility is preserved
s’(t) = s(tE)
fk’ = fE dE dk
s’(tE) = s(t)
81 82
Proof by contradiction
EDF
U lub 1 Assume Up 1 and is not schedulable
Show that Up > 1
This means that a task set is schedulable
by EDF if and only if Equivalent to show:
Up 1 unschedulable Up > 1
83 84
10/14/2019
deadline miss
deadline miss
t1 t2
t1 t2 d k t 2 n
(t 2 t1 ) n
t t
Let t2 be the first instant at which a deadline is missed. C p (t1 , t 2 ) C
rk t1
k
i 1 Ti
Ck 2 1 Ck (t 2 t1 )U p
i 1 Ti
Let [t1, t2] be the longest interval of continuous utilization,
before t2, such that only jobs with d t2 are executed in [t1, t2]
C p (t1 , t 2 ) (t 2 t1 )U p
Let Cp(t1,t2) be the total demand in [t1, t2]. 85 86
idle
Up 1 schedulable
deadline miss
Proof by optimality
Find any algorithm for which the above
t1 t2 condition holds;
Since a deadline is missed, we must have: (t 2 t1 ) C p (t1 , t 2 ) Then, for the EDF optimality, the above
condition also holds for EDF.
and since C p (t1 , t 2 ) (t 2 t1 )U p we have: (t 2 t1 ) (t 2 t1 )U p
Consider the Proportional Share algorithm: With this algorithm, a task executes in each period for:
in every interval of length it schedules a fraction i: Ti T
i i U i TiU i Ci
i = Ui i i i i
t
Ti
1 2 3 1 2 3 1 2 3 n
t
Feasibility is ensured if
i 1
i that is if
n
U
i 1
i Up 1
89 90
10/14/2019
L 0, g (0, L ) L d i t2
g (t1 , t 2 ) C
ri t1
i
91 92
1
0 L 2
L Di Ti 0 2 4 6 8 10 12 14 16
g i (0, L) Ci
Ti g(0, L)
L
8
n
L Di Ti
g (0, L)
6
Ci 4
i 1 Ti
2
0 L
93 94
n
LU (T D )U
i 1
i i i
95 96
10/14/2019
n
G (0, L) LU (T D )U
i 1
i i i
L L D , g (0, L ) L
G(0, L)
n
(T D )U
i i i
L* i 1 g(0, L) D = {dk | dk min (H, L* )}
1U
H = lcm(T1, … , Tn)
for L > L* n
g(0,L) G(0,L) < L (T D )U
i i i
L L* i 1
L* 1U
97 98
101 102
10/14/2019
polynomial: O(n) pseudo-polynomial EDF requires explicit kernel support for deadline
EDF Processor Demand Analysis scheduling, but gives other advantages.
Ui 1 L 0, g (0, L) L
103 104
2
A set of tasks is harmonic if every pair of 8 16 24
A common misconception 2 2 2
U 0.917
The RM schedulability bound is 1 if every 4 8 12
period is multiple of the shortest period. Any increase in the Ci’s makes the system unschedulable
105 106
3 2. Transient overload
0 2 4 6 8 10 12 14 16 18 20 22 24
107 108
10/14/2019
1 1
0 8 16 24 32 40 48 56 64 72 80 0 8 16 24 32 40 48 56 64 72 80
2 2
0 12 24 36 48 60 72 84 0 12 24 36 48 60 72 84
3 3
0 20 40 60 80 0 20 40 60 80
High priority tasks execute at the proper rate All tasks execute at a slower rate
Low priority tasks are completely blocked No task is blocked
109 110
2 (3/9)
0 9 18 27
U = 1.25
Ti T’i 3(1/20)
1
1 8 10
0 20
2
8 10
4(1/30)
2 12 15 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30
12 15
3 3 20 25
20 25
111 112