ESD UNIT III Lecture 03 Task Scheduling Rate Monotonic
ESD UNIT III Lecture 03 Task Scheduling Rate Monotonic
5
5
10
10
T
1
T
2
T
3
RM - Schedulability Analysis
Real-time system is schedulable under
RM
if and only if R
i
T
i
for all task (T
i
,C
i
)
RM Utilization Bound
Real-time system is schedulable under
RM if
U
i
n (2
1/n
-1)
RM Utilization Bound: An Example
Real-time system is schedulable under RM if
U
i
n (2
1/n
-1)
Example: T
1
(4,1), T
2
(5,1), T
3
(10,1),
U
i
= 1/4 + 1/5 + 1/10
= 0.55
3 (2
1/3
-1) 0.78
Thus, {T
1
, T
2
, T
3
} is schedulable under RM.
RM Utilization Bounds
0.5
0.6
0.7
0.8
0.9
1
1.1
1 4 16 64 256 1024 4096
The Number of Tasks
U
t
i
l
i
z
a
t
i
o
n
RM Utilization Bound
Real-time system is schedulable under RM
if
U
i
n (2
1/n
-1)
Rate Monotonic Algorithm Analysis
Amongst a set of tasks, the task that occurs most frequently is assigned
highest priority
Priority of each task is fixed, i.e., Static priority
Preemptive scheduling
Proposed by Liu & Leyland (1973)
RM is considered optimal in the sense that if a set of tasks cannot be
scheduled by this algorithm, it cannot be scheduled by any other
algorithm that assigns static priorities
Despite being optimal, RMS has a limitation: CPU utilization is bounded
and it is not always possible to fully maximize CPU resources.
Properties of Utilization Bound U(n) = n(2
1/n
-1)
n Bound for Utilization
1 100% One task
2 83% Two tasks case
3 78%
4 76%
69.3% = (ln 2) Infinite task case
CPU Utilization and Utilization Bound
In RM, one tasks CPU Utilization U
i
= C
i
/T
i
n tasks CPU Utilization U = C
i
/T
i
= U
i
+ U
2
+ + U
n
Utilization Bound for n tasks U(n) = n (2
1/n
-1)
Utilization Bound Theorem:
Consider a set of n independent periodic tasks. They are
schedulable under RM if U U(n)
C
i
/T
i
n (2
1/n
-1)
Conclusion:
01] If U is less than 0.693, the tasks are definitely schedulable as per RM
02] If 0.693 < U < 1, then RM schedule is still valid but there is no
guarantee of success
03] If U > 1, the tasks are definitely not schedulable as per RM
Necessary Conditions for RM Schedulability
01] Individual Utilization
For each task, C
i
T
i.
This means that for each task, the
execution time should be equal or less than its period.
02] Total Utilization U = [C
i
/ T
i
] 1
This indicates that sum of all utilization ratios cannot
exceed 1. [C
i
/ T
i
] = 1 means that CPU is 100% time
loaded. It cannot do any extra task.
Worst Case Response Time R
i
for RM
( ) i
i
i
i j
Tj HP T
j
R
R C C
T
e
(
= +
(
(
(
Here HP(T
i
) is set of higher priority tasks than T
i
In this equation R
i
appears both on left as well as right side
of equality sign
This implies that the equation should be solved by multiple
Iteration Method
Worst Case Response Time for RM
( 1)
( ) i
ni
n i i j
Tj HP T
j
R
R C C
T
+
e
(
= +
(
(
(
Step-II Calculation of R
B
Medium priority task B has only one task i.e. Task C in hp (B) set. This is
because task C has higher priority than task B
Hence R
B
= 20
Step-III Calculation of R
C
and Conclusion
There is no task having higher priority than Task C. So
set hp (C) is empty, Hence R
C
= C
C
= 10
So far we have calculated R
A
= 52, R
B
= 20 and R
C
= 10
Now the table of tasks is rewritten with worst-case
response times added in last column
Conclusion:
In each of the three tasks it is seen that R
i
D
i
Hence this task set is schedulable under RM
How to solve RM Numerical
Three tasks T1, T2 and T3 have periods of 50, 100 and 200 and execution
times as 10, 20 and 50 respectively. Assume Period T
i
= Deadline D
i
(a) What is utilization of each task?
(b) What is total CPU Utilization Ui?
(c) Calculate Utilization Bound U(n)
(d) Mention priority of each task
(e) Is the task set schedulable as Utilization Bound Test?
(f) Draw Time Line Diagram of the three tasks
(g) Draw Time Line Diagram of RM Scheduling sequence of the three
tasks
(h) Find out worst case response times R
T1
, R
T2
and R
T3
(i) With reference to worst case response times, is the task set RM
schedulable?
Step-I Calculate U
i
and U
i
Ui = 0.20 + 0.20 + 0.25 = 0.65
U(n) = U(3) = 3(2
1/3
1) = 0.78
Since U < U(n), the task set is RM schedulable as per
Utilization Bound Test
Task with lowest period has highest priority. Hence T1 has
highest priority, T2 medium and T3 lowest priority
Step-II Time Line Diagram of RM Schedule of Three Tasks
Summary of RM Tests
Utilization bound test is simple but conservative
Worst Case Response Time test is more exact
but also more complicated
UB and Worst Case Response Time tests share
the same limitations:
all tasks run on a single processor
all tasks periodic and non-interacting
deadlines always at the end of the period
no interrupts
rate monotonic priorities assigned
zero context switch overhead
tasks do not suspend themselves