Real Time System - : BITS Pilani
Real Time System - : BITS Pilani
Lecture 7
BITS Pilani Rekha.A
Pilani Campus
Priority driven schedulers
BITS Pilani Rekha.A
Pilani Campus
LRT (Latest Release Time)
Algorithm
schedule is built from right to left (in reverse chronological order)
It treats release time as deadline and deadline as release time and schedule
the jobs backward starting from latest deadline in ‘priority-driven’ manner.
Example
J
T2 J2,1 J2,1 J2,2 J2,2 2, J2,3
2
0 1 2 3 4 5 6 7 8 9 10 11
J
T2 J2,1 J2,1 J2,2 J2,2 2, J2,3
2
0 1 2 3 4 5 6 7 8 9 10 11
0 3 6 8
8
BITS Pilani, Pilani Campus
Exercise
The feasible interval of each job in the precedence graph is given next to its
name. The execution time of all jobs are equal to 1.
a) Find out the effective release times and deadlines of the jobs
9
BITS Pilani, Pilani Campus
Exercise – Answer (a)
10
BITS Pilani, Pilani Campus
Exercise – Answer (a)
11
BITS Pilani, Pilani Campus
Exercise – Answer (b)
EDF Schedule Jobs Effective Effective
Time 0: J1 is released and scheduled. Release Deadlines
Times
Time 1: J2, J4, J7 gets released. J2 and J4 have same deadlines,
J1 0 4
which is earlier than that of J7. But J4 is predecessor of J2.
Hence we have to schedule J4. J2 1 4
Time 2: Out of J2 and J7, J2 has earlier deadline i.e. 4, so gets J3 3 5
scheduled.
Time 3: All other jobs gets released. J3 and J5 have earlier J4 1 4
deadlines i.e. 5. But J5 is predecessor of J3. So we have to J5 3 5
schedule J5.
J6 3 10
Time 4: J3 gets scheduled, since it has the earliest deadline i.e. 5.
Time 5: J6 gets scheduled, since it has the earliest deadline i.e. J7 1 12
10. J8 3 12
Time 6, 7, 8: J7, J8, J9 have same deadlines i.e. 12, so same
priority. But J7 is predecessor of J8 and J8 is predecessor of J9. J9 3 12
So they have to be scheduled in the order J7, J8 and J9.
J1 J4 J2 J5 J3 J6 J7 J8 J9
0 1 2 3 4 5 6 7 8 9
12
BITS Pilani, Pilani Campus
Exercise – Answer (b)
Jobs Effective Effective
J1 (0, 10] J2 (1, 4] J3 (0, 5] Release
Times
Deadlines
J1 0 4
J2 1 4
J1 J4 J2 J5 J3 J6 J7 J8 J9
0 1 2 3 4 5 6 7 8 9
13
BITS Pilani, Pilani Campus
Rate Monotonic (RM)
Algorithm
Fixed priority algorithm
Shorter the period, higher the priority
Rate is inverse of the period. Hence higher the rate, higher the priority. – so the name ‘rate
monotonic’
T1 has shortest period (i.e. 4), so should have higher priority, followed by T2 and T3.
T1 get scheduled at after 4 time units i.e at times 0, 4, 8, 12, 16, 20, ...
T2 gets scheduled at time units 1, 5, 11 for 2 time slots. When T2 gets released at time 15, it is
given this slot, preempting T3. But at time 16, T1 gets released. It gets scheduled preempting
T2. Once T1 is done, T2 again gts scheduled at time 18.
T3 gets scheduled in the remaining slots 3, 7. It gets time slot 9, since T1 is done and T2 is not
released that time. But it gets preempted in the next slot because T2 gets released. Again it gets
scheduled in slot 13 and 14. With this T3 completes for one period 20.
T1 T2 T2 T3 T1 T2 T2 T3 T1 T3 T2 T2 T1 T3 T3 T2 T1 T2 T1
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 29 20
14
BITS Pilani, Pilani Campus
Rate Monotonic (RM)
Algorithm
T1
J1,1 J1,2 J1,3 J1,4 J1,5 J1,6
T2
J2,1 J2,2 J2,3 J2,4 J2,4
T3
J3,1 J3,1 J3,1 J3,1
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
15
BITS Pilani, Pilani Campus
Deadline Monotonic (DM)
Algorithm
Fixed priority algorithm
Shorter the relative deadline, higher the priority
When the relative deadlines of every task is proportional to their period, the schedule produced by RM and
DM algorithms are identical.
But when the relative deadlines are arbitrary, DM may produce a feasible schedule when RM fails.
Example:
T1 = (50, 50, 25, 100), T2 = (0, 60, 10, 20), T3 = (0, 125, 25, 50)
According to DM algorithm, T2 has highest priority because its relative deadline is 20.
Similarly T1 has lowest priority and T3 has priority in between.
J J
T1 J1,1 J1,1 J1,2 1
J1,3 1
J1,4
, ,
2 3
T3 J3,1 J3,2
0 10 20 35 40 50 60 70 80 85 100 120 130 140 155 160 180 190 200 220 225
16
BITS Pilani, Pilani Campus
Schedulable Utilization
A scheduling algorithm can feasibly schedule any set of
periodic task on a processor if the total utilization of the tasks
is equal to or less than the schedulable utilization of the
algorithm.
17
BITS Pilani, Pilani Campus
Schedulable Utilization
Example for U > 1:
Consider EDF schedule for tasks: T1 = (2,1), T2 =(5,3)
Total utilization U = 1/2+ 3/5 = 0.5 + 0.6 = 1.1
J2,2 missed its deadline 10
0 1 2 3 4 5 6 7 8 9 10 11
18
BITS Pilani, Pilani Campus
Relative Merits
Criterion to measure performance: Schedulable Utilization
So higher the schedulable utilization, better is the algorithm.
An algorithm whose schedulable utilization is 1, is an optimal
algorithm.
Optimal dynamic-priority algorithms outperforms fixed-
priority algorithms in terms of schedulable utilization.
But advantage of fixed-priority algorithms is predictability.
19
BITS Pilani, Pilani Campus
Example
Rate Monotonic
Algorithm
J1,1 J2,1 J1,2 J2,1 J1,3
0 1 2 3 4 5 6 7
EDF Algorithm
21
BITS Pilani, Pilani Campus
Schedulablity Test of EDF
Algorithm
Schedulablity condition for EDF algorithm:
n
ek
k 1 min( Dk , pk )
1
22
BITS Pilani, Pilani Campus
Example
J1 J2 J3
n
ek
r 0 0 0
1
k 1 min( Dk , pk )
e 1 1 5
d 1 2 5
24
BITS Pilani, Pilani Campus
Optimality of RM Algorithm
Theorem:
26
BITS Pilani, Pilani Campus
Sufficient schedulability
condition for RM algorithm
Theorem:
A system of ‘m’ independent, preemptable periodic tasks
with relative deadlines equal to their respective periods can
be feasibly scheduled on a processor according to RM
algorithm if its total utilization ‘U’ is less than or equal to
1
URM m(2 1)
m
27
BITS Pilani, Pilani Campus