Professional Documents
Culture Documents
The Rate Monotonic Scheduling Algorithm: Exact Characterization and Average Case Behavior
The Rate Monotonic Scheduling Algorithm: Exact Characterization and Average Case Behavior
The Rate Monotonic Scheduling Algorithm: Exact Characterization and Average Case Behavior
166
CH2803-5/89/0000/0166/$01.00 0 1989 JEEE
job of that task; however, the analysis presented here are ready at their initiation times, two
extends to the case of more general deadlines. conclusions follow. First, jobs of zi will be
preempted only by higher priority jobs, and they
will preempt any lower priority jobs. Thus only
2. Problem Formulation zl. . . . ,zi need be considered to determine if zi
Consider a set of n periodic tasks zl, ...,.7, Task zi has a can be scheduled. Second, starting at a critical
period Ti, a computation requirement, C , and a phasing instant, the processor will not idle before either
relative to 0, 4, with 0 I 4 c Ti. This means that jobs the first job of zi is finished or it misses its
deadline, whichever occurs first.
corresponding to task zi are initiated at times $ + kT;, k 2
0. The job initiated at time Ii + kTi has Ii + (k+l)Ti as its Task zi completes its computation requirement
deadline, the initiation time of the next job. We label the at time t E [O,Ti], if and only if all the requests
tasks so that T, I T2 I . .. IT,. Consequently, zi from all the jobs with priority higher than i and
receives priority i. We assume tasks are ready to run at C , the computation requirement of zi, are
their initiation times, tasks can be preempted instantly (and completed at time t. The total of such requests is
so ignore all blocking) and ignore all overhead such as task given by Wi(t), and they are completed at t if and
swapping times.
only if Wi(t) = t and Wi(s) > s for 0 I s c t .
Liu and Layland proved that the worst case phasing Dividing by t, we find equivalently Li(t) = 1. It
occurs when Ii = 0 for 1 I i I n . This is called a critical
follows that a necessary and sufficient condition
instant in which all tasks are simultaneously instantiated. for zi to meet its deadline is the existence of a t
Using this concept, Liu and Layland also proved that the
task set is schedulable (all deadlines of all jobs of every E [O,Ti] such that Li = 1. Consequently, a
task are met) using the rate monotonic algorithm if the first necessary and sufficient condition for oi to meet
job of each task can meet its deadline when it is initiated at its deadline under all phasings is Li I 1. This
a critical instant. Theorem 1 gives a necessary and
sufficient condition for the first job of each task to meet its proves the first assertion.
deadline under the worst case phasing. To determine if a The second assertion follows directly from the
task can meet its deadline under the worst case phasing, we fist. The entire task set is schedulable if and
need to consider the processor demands made by the task only if each of the tasks is schedulable. This
set as a function of time. If we focus on tasks zl, . . . ,zi,
means that Li I 1 for each i. Equivalently,L 5
then the expression
1 is necessary and sufficient for the task set to be
c 1
wit)= cj.rt l q ,
j =1
schedulable.
The characterizationof schedulability given in Theorem
gives the cumulative demands on the processor made by 1 requires a minimization over the continuous variable t E
these tasks over [O,t] when 0 is a critical instant. For later [0, Ti]. In fact, only a finite number of times t need to be
notational convenience, we define checked. The function Li(t) is piecewise monotonically
Li(t) = WJOIt, decreasing, that is rtITiit is strictly decreasing except at a
finite set of values called the rate monotonic scheduling
Li = mi' (0< I <~,.)'Jtl* points. When t is a multiple of one of the periods Tj,
L = m a x ( l < i < nL)i' l I j S i , the function has a local minimum, is left
Given this notation, we can conveniently express the continuous and jumps to a higher value to the right.
exact criterion for a task or task set to be schedulable by Consequently, to determine if zi can meet its deadline one
the rate monotonic algorithm. need only search over these local minima, the multiples of
Tj ITi for 1 I j I i . Specifically,let
Theorem 1: Given periodic tasks zl, . . . ,zn,
l.zi can be scheduled for all task si= (R.T.I lj= 1,...,i;1,...,L T ~ ~ J ) .
phasings using the rate monotonic The elements of Si are the scheduling points for task i,
algorithm if and only if Li I 1. the deadline of task i and the arrival times of tasks of
priority higher than i before the deadline of task i assuming
2. The entire task set can be scheduled a critical instant phasing. For example, suppose we
for all task phasings using the rate consider three tasks with periods T, = 5, T2 = 14, and T3 =
monotonic algorithm if and only if L 30. The scheduling points are given by S = ( 5 ) , S, = (5,
I1.
10, 14) and S, = (5,10,14,15,20,25,28,30). It follows
Proof: Given the worst case phasing was that
proved by Liu and Layland to be a critical instant
and we require schedulability for all task L, = min ( I E &t).
phasings, we can restrict attention to the worst One can modify the criteria of Theorem 1 to give
case. Given the assumptions of perfect Theorem 2: Given periodic tasks zl, . . . ,Z,,
preemption, no blocking, no overhead and jobs
I67
1. zi can be scheduled for all task 3. Stochastic Characterization
phasings using the rate monotonic The necessary and sufficient conditions for
algorithm if and only if schedulability of a task set given in either Theorem 1 or 2
give an exact condition for the rate monotonic algorithm to
Li = min ( t E si)Wi(t)/rI1. be able to schedule a given task set, but they do not, by
themselves, offer any insight into the conditions under
2. The entire task set is schedulable for which the rate monotonic algorithm can exceed its worst
all task phasings using the rate case utilization bound. One approach is to generate a task
monotonic algorithm if and only if set randomly and then use the conditions to determine the
utilization level at which it fully utilizes the processor. In
L=max(ls,,,)L,Il. most average case analyses of algorithms, a simple
We present a simple example to illustrate Theorem 2. probability model is used to generate the cases from which
Suppose we have a task set with three periodic tasks for the average results are derived. For example, in bin
which Vi = CiF2 packing, one generally considers unit size bins and
uniformly distributed objects to pack. In the travelling
salesman problem, one usually picks cities uniformly in a
Task 2,: C, = 20 ;T , = 100 ; U, = 0.200 region, and in sorting algorithms, one usually assumes
uniformly distributed permutations of objects to sort. In
Task T ~ :C2= 40 ;T2 = 150 ;U2 = 0.267 the case of the rate monotonic algorithm, it is possible to
consider a very general model of randomly generated task
Task 73: C3 = 100 ; T3 = 350 ; U3 = 0.286 sets. Specifically, we introduce a cumulative distribution
The total utilization of these three tasks is 0.753, which function (c.d.0 FT(t) for the task periods and a c.d.f. Fc(c)
is below the Liu and Layland bound for tasks: 3(21n for the task computation requirements. First, we draw a
- 1) = 0.779. Hence, we know these three tasks are random sample oftask periods, T1,...,Tn, from FT(t). Next
schedulable using the rate monotonic algorithm, i.e.! Cey we label them so that T, I T2 5 . . . I T,. Finally, we
wlll meet thelr deadlmes If 2, 1s w e n the highest PnOntY, draw a random sample of computation requirements,
72 the next highest, and 'c3 the lowest. The remaining C , ,...,Cn, from Fc(c). The resulting pairs (C,,T,), ... ,
24.7% processor capacity can be used for low p-onty (Cn,Tn)constitute a random task set.
background processing. However, we can also use it for
additional hard real-time comDutation. We think of the Cis and Tis as providing relative
computation requirements and periods. The task set must
Suppose we replace 7,'s computation with one that is be scaled to create an appropriate utilization. In particular,
more accurate but requires 40 rather than 20 units of time. we multiply each Ci by a small factor A and systematically
The total processor utilization increases from 0.753 to
0.953. Since the utilization of the first two tasks is 0.667, increase A to a threshold value A* at which some task
which is below the Liu and Layland bound for two tasks, deadline is missed assuming that the task phasing
2(21n - 1) = 0.828, the first two tasks cannot miss their corresponds to a critical instant. The associated utilization
deadlines. For task T ~ we , use Theorem 2 (part 1) to check
of the task set at which a deadline is first missed is a
measure of the threshold at which the rate monotonic
whether the task set is schedulable. Here i=3 and S3 = algorithm misses a deadline. The quantity*A is a random
{ 100,150,200,300,350). variable as is the breakdown utilization, U,. We offer an
Task 73 is schedulable if any of the following equations exact formula for A* and U,* and an approximate
holds:
characterization of the random variable, U:.
C 1 + C 2 + C 3 IT I 4 0 + 4 0 + 100 > 100 For the randomly generated and scaled task set, the
criterion developed in Theorem 2 indicates that the task set
or 2C1+C2+C35T2 8 0 + 4 0 + 1 0 0 > 150 is schedulable if and only if
I68
3.1. Example 1
[C",1uil/[max(l <i<,,)min( l e si,wi~t)!t (4) Assume n = 2, C, = C,, and the task periods are chosen
where Ui = CJr,. according to a Uniform [1,2] distribution. Let R = T P 1 ,
The numerator is merely the total utilization of the task so 1 I R 5 2 . It follows that
set. The maximizing index i in the denominator picks the
task in the task set whose deadline will be missed if the U: = (R+l)/min ( 2 ~ 3 ) . (5)
scaling factor is further increased, and the associated The probability density function @.d.f.) of R is given by
minimizing t picks the time at which that task will meet its
deadline. The form for the breakdown utilization given in )r('f = (4/r2)-1, 1I r I 2 (6)
(4) is useful for conducting simulation studies of the
average case behavior of the rate monotonic algorithm. It is straightforward to find the p.d.f. of U: and its mean
Some simplifications of this formula are sometimes value. In particular, its density function is given by
possible. For example, if FT(1) = 0 and FT(2) = 1, so 1 I
5
TnD1 52, then the maximum in the denominator occurs AX)= 12/(3~-1)~+5-2/(2~-1)~, i;<x< 1, (7)
when i = n. We formulate this as a theorem, one which
offers a simplification of the calculation of the breakdown and this p.d.f. has mean value equal to .917, which is larger
utilization in this case. than the Liu and Layland bound of .828. Indeed, the
assumption C, = C, increases the worst case bound to
Theorem 3: Suppose 1S T , 5 . .. IT,,52. .833, larger than the usual bound of .828.
Then
n
4. Asymptotic Approximation
*
The quantity U,,is a random variable, one which is a
complicated function of the Cis and Tis. Liu and Layland
Proof: We define
proved n(2lm-1) I U: I 1. We wish to offer insight into
1 *
the size of the random variable U,, as a function of FT(t)
and Fc(c). In this section, we present an asymptotic
From the defi&tion of Si and the fact that approximation for this random variable as n +00, that is
LT,,@~. the minimum in 6i must occur at for large task sets.
*
some T., l l j l i . We prove 6,,26, for all i. The expression for U,, given in (4) involves sums of
J
This will allow us to conclude that 6,,26, for all i random variables. To simplify the presentation, we will
and will complete the proof of the theoxem. assume that the random variables Ci and Ti are bounded
and the largest period ratio is also bounded. Consequently,
Suppose the minimum for 6i+1is assumed at t we assume l I T i I B for some finite B. In addition, we
= Tj where j S i . Then 6i+1 assume that FT has a density function which is strictly
=[2(C1+. . . +CF1)+Cj+. . . +Ci+,]/Tj positive over the interval [1,Bl .
1 [2(C1+ . . .+CF1)+Cj+ . . . +C,)l/Tj The appearance of sums of random variables in the
1tii, numerator and denominator of (4) allows for the
since the latter is the t=Tj component of 6? application of convergence theorems from probability
theory. In particular, the numerator of (4) , after dividing
Suppose instead that the minimum for Si+, is by n, is a sum of independent, identically distributed
assumed at t = Ti+l. Then 6i+1 utilization ratios, Ui = CiD2 It follows that
=[2C1+ . . .+2Cl+Ci+l]/Ti+1
2 (Cl+ . . . +Ci)/Tl
26,
x=,
Ui/n +E(Ui) = E(C)-E(l/T) a.s.
The latter inequality holds by the presumed
(8)
since Ti+, 5 2T, and Ci+l 2 0. independence of Ci and Ti. Although the periods have
been labeled to be in increasing order, since the sum
In either case, 6,+, 2 6,. Consequently, the contains all the terms, it is independent of the particular
maximum occurs when i = n, and attention can permutation used. Finally, the central limit theorem could
be restricted to 6, which completes the proof. be used to create a normal approximation to the numerator.
* The denominator of (4) requires more care. After
Before giving an asymptotic analysis of U,,, we present dividing by n, the denominator becomes
a simple example.
max (, 5isn)min si,zj=l
cjTt/$Itn. (9)
For fixed t and i, the Tj have been ordered to be non-
I69
decreasing, so the sum in (9) involves the i smallest
periods. As such, the T. are no longer independent and
identically distributed. devertheless, the behavior of the
order statistics from a random sample is well understood Using this notation, we have the following theorem.
(see for example [7]). In particular, if we let i = LanJ, then
Theorem 4:
Ti+F;.l@) U.S. 1. Under Assumption 1 with B 12,
where
Ui+E(lm/h as n+-, a.s.
G(a)=Fil(a) = inf ( x IF d x ) 2 a). 2. Under Assumption 1 with B 2 2,
Moreover, T, ,...,Ti is, for large n, approximately a
random sample from the c.d.f. of T conditioned on the U;+E(lm/w as n+-, as.
event ( TI ~;'(a) 1. 3. For B 2 2 and under Assumptions 1
and 4 or if FT is uniform [1,B], then
loa
I ( ~=) rs/G(f)i dtlS.
I 70
4.2. Example 2 than the worst case behavior as suggested by simulations.
Suppose that the task periods are drawn from a uniform The formula of exact characterizationcan be used to check
[1,B] distribution with B12. Both numerator and if a given task set is schedulable. The analysis can be
denominator are easy to compute. In particular, E(1m = generalized to allow for more general task deadlines, in
Dg,(B)l/(B-l) and min ( o s x s ,]h(x)=l. Consequently particular when task deadlines need not be at the end of the
task period. The analysis can also be applied to the case in
U: -+ [ L ~ ~ , ( B ) I / ( B - I )1, I B I2, n +w, a.s. which task synchronization must be considered, and when
the priority ceiling protocol is used Finally, the analysis
If B > 2 , then the numerator is unchanged; however, can be carried out when there is insufficient priority
the denominator must be recomputed. It becomes granularity, that is, when there are fewer priority levels
LEA1
available than there are task periods. This arises in real-
time communication where the number of priority bits is
d = [(B/LBJ)+ C i=2
I/~I/(B-~). inherently limited.
Consequently, for B 2 2 and as n +m, References
U: + [log,(B)II[BI[BJ+ c
LBJ-1
i=2
(WI, a.s.
1. Lehoczky, J. P. and Sha, L. "Performance of Real-
Time Bus Scheduling Algorithms". ACM Performance
Evaluation Review, Special Issue Vol. 14, No. I (May,
The above example is particularly interesting, because it 1986).
provides an illustration of a situation in which the
asymptotic average case behavior coincides with the worst 2. Lehoczky, J. P., Sha L. and Strosnider,J. "Aperiodic
case behavior. Specific$ly, when B = 1, the average Case Scheduling in A Hard Real-TimeEnvironment". Proc.
asymptotic performance 1s 1 and decmlses monotonlcally IEEE Real-Time Systems symp. (19871,261-270.
until it reaches the level Loge2 when B = 2, the Liu and
Layland worst case bound. It then slowly increases to 1 as 3. Liu, C. L. and Layland J. W. "Scheduling AIgorithms
B +00. The following table presents the limiting for Multiprogrammingin a Hard Real Time Environment".
performance values, i.e. breakdown utilization values for JACM 20 (I)(1973), 46 61. -
an assortment of values of B.
4. Liu. J. W. S., K. J. Lin and S. Natarajan. "scheduling
-
-
B Asymptotic real-time, peri&c jobs using impreciseresults".
Performance Proceedings of the IEEE Real-Time Systems Symposium
1.o 1.OOo (1987), 252-260.
1.5 .811
2.0 .693 5. R. Rajkumar. Task synchronization in real-time
3.O .732 systems. Ph.D. Th., Carnegie Mellon University, August,
5.0 .I73 1989.
10.0 .814 6. Sha, L., Lehoczky, J. P. and Rajkumar, R. "Solutions
20.0 .844 for Some Practical Problems in Prioritized Preemptive
40.0 .867 Scheduling". IEEE Real-Time Systems Symposium
80.0 .885 (1986).
100.0 .889
7. Shorack, G. and J. Wellner. Empirical Processes with
As B increases without limit, the limiting value of the
breakdown utilization converges to 1. Nevertheless, the Applications to Statistics. John WiIey, New York, 1986.
rate of convergence is quite slow. For randomly generated 8. Sprunt, B., Lehoczky, J. and L. Sha. "Exploiting
task sets consisting of a large number of tasks whose unused periodic time for aperiodic service using the
periods are drawn from a uniform distribution with largest extended priority exchange algorithm". Proceedings IEEE
period ratio ranging from 50 to 100, 88% is a good
approximation
__ to the threshold of schedulability for the Real-Time Systems Symposium (1988), 25 1-258.
rate monotonic algorithm. The slow rate of convergence 9. Sprunt, Kirk,D. and Sha. llpriority-driven
means that a large task set is required for the breakdown
utilization to be qual to the constant preemptive 1/0controllers for real-time systems".
in theorem 4. This underscores the importance of Proceedings of 15th International Symposium on
developing normal approximations where possible to Computer Architecture (1988), 152-159.
sharpen th; results in fi-eorem 4.
10. Sprunt, B., Sha, L., and J. Lehoczky. "Aperiodic task
scheduline for hard-real-timesystems". Real-Time
Systems fi989), 27-60.
5. Summary and Conclusion
In this paper, we have provided an exact 11. Strosnider,J. K., Marchok, T. and J. Lehoczky.
characterization and a stochastic analysis for a randomly "Advancedreal-time scheduling using the IEEE 802.5
generated set of periodic tasks scheduled by the rate Token Ring". Proceedings of the IEEE Real-Time Systems
monotonic algorithm. The stochastic analysis has shown Symposium (1988),42-52.
that the average scheduling bound is usually much better
171