Priority-Based Scheduling (Periodic Tasks)
Priority-Based Scheduling (Periodic Tasks)
Priority-Based Scheduling (Periodic Tasks)
1
Example
P1 P2 P3
• Period (Ti) 20 50 30
• WCET (ei) 10 10 5
• Priority high low medium
0 10 20 30 40 50 60 70
time
preemption
Schedulability Test
• For n processes, RMS will guarantee their schedulability
if the total utilization U does not exceed the guarantee
level G = n * (21/n - 1)
Process Set A
Process Period ComputationTime Priority Utilization
T C P U
a 50 12 1 0.24
b 40 10 2 0.25
c 30 10 3 0.33
2
Timeline for Process Set A
Process
Preempted
c
Executing
0 10 20 30 40 50 60
Time
Process Set B
Process Period ComputationTime Priority Utilization
T C P U
a 80 32 1 0.400
b 40 5 2 0.125
c 16 4 3 0.250
Process Set C
Process Period ComputationTime Priority Utilization
T C P U
a 80 40 1 0.50
b 40 10 2 0.25
c 20 5 3 0.25
3
Timeline for Process Set C
Process
0 10 20 30 40 50 60 70 80
Time
R i ≤ Di
Ri = Ci + I i
Calculating R
During R, each higher priority task j will execute a number of
times:
$R "
Number of Releases = # i !
#Tj !
The ceiling function gives the smallest integer greater than the fractional
number on which it acts. So the ceiling of 1/3 is 1, of 6/5 is 2, and of 6/3 is 2.
4
Reponse Time Equation
%R #
Ri = Ci + ! $ i "C j
j&hp ( i ) T
$ j"
Where hp(i) is the set of tasks with priority higher than task i
% win #
win +1 = Ci + ! $ "C j
j&hp ( i )
$ Tj "
0 1 2 n
The set of values wi , wi , wi ,..., wi ,.. is monotonically non decreasing
When win = win +1 the solution to the equation has been found, wi0
must not be greater than Ri (e.g. 0 orCi )
Process Set D
Process Period ComputationTime Priority
T C P
a 7 3 3
b 12 3 2
c 20 5 1
wb0 = 3
Ra = 3 $3"
wb1 = 3 + # ! 3 = 6
#7!
2 $6"
wb = 3 + # ! 3 = 6
#7!
Rb = 6
wc0 = 5
$5" $ 5 "
wc1 = 5 + # ! 3 + # 3 = 11
#7! #12 !
!
$ 11 " $ 11 "
wc2 = 5 + # 3+ # 3 = 14
#7 ! ! #12 !!
$14 " $14 "
wc3 = 5 + # 3+ # 3 = 17
# 7 !! #12 !!
5
Revisit: Process Set C
Process Period ComputationTime Priority Response
time
T C P R
a 80 40 1 80
b 40 10 2 15
c 20 5 3 5
• The combined utilization is 1.0
• This was above the ulilization threshold for three
processes (0.78), therefore it failed the test
• The response time analysis shows that the process set
will meet all its deadlines
• RTA is necessary and sufficient
6
Deadline-Monotonic Algorithm (DM)
• Fixed-priority
• Uses relative deadlines: the shorter the relative deadline,
the higher the priority
• RM and DM are identical if the relative deadline is
proportional to its period
• Otherwise DM performs better in the sense that it can
sometimes produce a feasible schedule when RM fails,
while RM always fails when DM fails
Example
T1
0 50 100 150 200 250
T2
0 62.5 125 187.5
T3
T1
0 50 100 150 200 250
T2
0 62.5 125 187.5
T3