di
Laxity
ci is the execution time and pi is the period, The term n(21/n -1) approaches ln 2, (0.69 as n ). - This condition is sufficient, but not necessary.
3
Schedulability check:
2/4 + 1/8 = 0.5 + 0.125 = 0.625 2(2 -1) = 0. 82
Active Tasks : {T1, T2}
Active Tasks : {T2} Active Tasks : {T1}
T11 0 2
T21 3 4
T12 6 8
Schedulability check:
2/4 + 4/8 = 0.5 + 0.5 = 1.0 > 2(2 -1) = 0. 82
Active Tasks : {T1, T2}
Active Tasks : {T2} Active Tasks : {T2, T1} Active Tasks : {T2}
T11 0 2
T21 3 4
T12 6
T21 8
Some task sets that FAIL the utilization-based schedulability test are also schedulable under RMS
This condition is both necessary and sufficient. - Least Laxity First (LLF) algorithm has the same schedulability check.
8
EDF/LLF (cont.)
Schedule construction (online) EDF/LLF: Task with the smallest deadline/laxity is assigned the highest priority (dynamic priority). At any time, the highest priority task is executed. It is optimal (i.e., whenever there is a feasible schedule, EDF can always compute it) when preemption is allowed and no resource constraint is considered. Given any two tasks in a feasible schedule, if they are not scheduled in the order of earliest deadline, you can always swap them and still generate a feasible schedule.
T11 0 1
T21 3
T21 5
T12 6
Unlike RMS, Only those task sets which pass the schedulability test are schedulable under EDF
10
Process Period, T T1 5 T2 7
WCET, C 2 4
T2
0 7 14 21 28 35
RMS schedule
T1 0 T2 0 7 14 21 28 35 5 10 15 20 25 30
Deadline miss
35
11
Resource sharing Periodic tasks Task can have resource access Semaphore is used for mutual exclusion RMS scheduling
12
Background Task State diagram Ready State: waiting in ready queue Running State: CPU executing the task Blocked: waiting in the semaphore queue until the shared resource is free Semaphore types mutex (binary semaphore), counting semaphore
13
14
T1 becomes ready to run and preempts T3. Then, T1 tries to enter its critical section by first trying to lock S. But, S is already locked by T3 and hence T1 is blocked. T2 becomes ready to run. Since only T2 and T3 are ready to run, T2 preempts T3 while T3 is in its critical section. Ideally, one would prefer that the highest priority task (T1) be blocked no longer than the time for T3 to complete its critical section. However, the duration of blocking is, in fact, unpredictable because task T2 got executed in between.
16
T1 Highest priority
T1
Resource S is A higher available and T1 priority task request for is scheduled resource S and waits for a gets blocked lower priority here task T1
T2 completes
Preempted by higher priority task T1 K2 T3 L1 T2 T3 completes Preempted by higher K3 priority task T2 T3
T3 is the Medium only priority active task T3 Least priority T1 and T3 share resource S
T2
K1 T3
17
Under this protocol, if a higher priority task TH is blocked by a lower priority task TL, because TL is currently executing critical section needed by TH, TL temporarily inherits the priority of TH.
When blocking ceases (i.e., TL exits the critical section), TL resumes its original priority. Unfortunately, priority inheritance may lead to deadlock.
18
T1 T2 T3
2 4 2
8 12 6
2 0 1
0 4 1
0 0 0
T2 and T3 have access to a shared resource R cix : Task duration before entering the critical section ciy : Critical section duration ciz : Task duration after the critical section ci = cix + ciy + ciz By RMS, T3 > T1 > T2
19
Schedules
RMS Schedule Locks R Direct blocking of T3 by T2 Preempted by T3 Release R T1 2 pi 8 c ix 2 c iy 0 4 c iz 0 T2 6 T3 T2 7 8 T1 10 T2 T3 T3 14 T2 16
T3 0 Task Ti T1 ci 2
11
12
Priority inversion of T3 by T1
T2
T3
4
2
12
6
0
1
4
1
0
0
T3
0
T1
T2
T3
T2
T3
T1
T3
T2
Inheritance blocking of T1 by T2
20
21
22
23
Thus T1 inherits the priority of T2 and proceeds to completion, thereby preventing deadlock situation.
24
T1
T2
Scheduler
25
Modifying the task parameters for RMS While using the RMS scheduler the task parameters (ready time) need to be modified in order to respect the precedence constraints
Ti Tj
Rj* Max (Rj, Ri*) where Ri* is the modified ready time of the task Ti Priority Prioi Prioj
26
T1 1
T3 2
T4 1
Task T1 T2 T3
Ri 0 5 0 0 0
Ci 1 2 2 1 3
Di 5 7 5 10 12
T5 3
T4 T5
27
Task T1 T2 T3
Ri 0 5 0 0 0
Ci 1 2 2 1 3
Di 5 7 5 10 12
T5 3
R5 = 0 R5 = 5
T4 T5
R5 = max(R3, R4,R5)
28
Task T1 T2 T3
Ri 0 5 0 5 5
Ci 1 2 2 1 3
Di 5 7 5 10 12
T5 3
R5 = 5
T4 T5
29
T3 2
R3 = 0
Assume all tasks of a connected component have the same period. Therefore, as per RMS all tasks will have a tie. We assign priorities to break the ties.
Modified Task Parameters
T4 1
R4 = 5
Task
Ri
Ci
Di
Priority
T1
T5 3
0 5 0 5
5
1 2 2 1
3
5 7 5 10
12
3 4 2 1
0
30
T2
R5 = 5
T3 T4
T5
Modifying task parameters for EDF While using the EDF scheduler the task parameters need to be modified in order to respect the precedence constraints
Ti Tj
Rj* Max (Rj, (Ri* + Ci)) Di* Min (Di, (Dj* Cj))
31
R4 = max(R1+C1, R2+C2,R4)
Initial Task Parameters
T3 2
T4 1
R4 = 0 R4 = 7
Task T1 T2 T3
Ri 0 5 0 0 0
Ci 1 2 2 1 3
Di 5 7 5 10 12
T5 3
R5 = 0 R5 = 8
T4 T5
R5 = max(R3+C3, R4+C4,R5)
32
Task T1 T2 T3
Ri 0 5 1 7 8
Ci 1 2 2 1 3
Di 5 7 5 10 12
T5 3
R5 = 8
T4 T5
33
T2 2
Task T1 T2 T3
Ri 0 5 1 7 8
Ci 1 2 2 1 3
Di 5 7 5 10 12
T5 3
D5 = 12
T4 T5
34
T2 2
Task
D4 = 9
Ri 0 5 1 7 8
Ci 1 2 2 1 3
Di 3 7 5 9 12
T1 T2 T3
T5 3
D5 = 12
T4 T5
35