Real-Tme Process Schedulng ktw@cse.ntu.edu.tw (Real-Tme and Embedded Systems Laboratory) Independent Process Schedulng Processes share nothng but CPU Papers for dscussons: C.L. Lu and James. W. Layland, Schedulng Algorthms for Multprogrammng n a Hard Real-Tme Envronment, JACM, Vol. 20, No.1, January 1973, pp. 46-61. Major references: Aloysus K. Mok, Fundamental Desgn Problems of Dstrbuted Systems for the Hard Real-Tme Envronment, Ph.D. dssertaton, MIT, 1983 Te-We Kuo and Aloysus K, Mok, Incremental Reconfguraton and Load Adjustment n Adaptve Real-Tme Systems, IEEE Transactons on Computer, 1997, IEEE 12th Real-Tme System Symposum, 1991.
Motvaton: Studyng: 2 days per 4 days Playng Basketball: 1.5 days per 3 days Case 1: Playng basketball (or studyng) s more mportant! 0 1 2 3 4 5 6 Case 2: Dong whatever s more urgent! 0 1 2 3 4 5 6 Questons: Can we fnd an optmal scheduler, that always produces a feasble schedule, whenever t s possble to do so? What does optmal means? Can we fnd a quck schedulablty test for a set of processes? Is t smple and accurate? Processes whose perods are more harmoncally related s lkely to be schedulable? Why? More accurate schedulablty tests possble? Better system confguratons can be found? How do we model schedulng overheads, such as the cost of context swtchng?
Tentatve Assumptons: Processes are ndependent. Processes are all perodc. We wll show you how to model sporadc processes and solve ther schedulablty problem later. The deadlne of a request s ts next request tme. A scheduler conssts of a prorty assgnment polcy and a prorty-drven schedulng mechansm. The paper of the week: C.L. Lu and James. W. Layland, Schedulng Algorthms for Multprogrammng n a Hard Real-Tme Envronment, JACM, Vol. 20, No.1, January 1973, pp. 46-61. Defntons The response tme of a request for a process s the tme span between the request and the end of the response to that request. A crtcal nstant of a process s an nstant at whch a request of that process has the largest response tme. A crtcal tme zone for a process s the tme nterval between a crtcal nstant and the end of the response to the correspondng request of the process. A crtcal nterval for a process s the tme nterval between a crtcal nstant and the deadlne of the correspondng request of the process. An observaton: If a process can complete ts executon wthn ts crtcal nterval, t s schedulable at all tme!
Theorem 1 [LL73] A crtcal nstant for any process occurs whenever the process s requested smultaneously wth requests for all hgher prorty processes. Proof. Case 1: TL does not run at t. TH TL t Case 2: TL runs at t. Tme Tme TH TL t Tme Tme Rate Monotonc Schedulng The rate monotonc prorty assgnment (RMS) assgns processes prortes accordng to ther request rates. Theorem 2 [LL73] If a feasble fxed prorty assgnment exsts for some process set, then the rate monotonc prorty assgnment s feasble for that process set. Proof. Start the proof from = 1. Exchange the prortes of τ and τ +1 f ther prortes are out of RMS order. Hnt: before: HPC -1 + c +1 + c p p + 1 p + 1 p + 1 p + 1 mply HPC - 1 c + 1 c p p + p + p + p p => after: HPC -1 + floor(p +1 / p ) c + c +1 p +1 where HPC -1 = CPU tme consumed by {τ,..., τ -1 } = p c p j j 1
An RMS example: Two processes wth p1 = 4, p2 = 5, and c1 = 2, c2 = 1. 0 1 2 3 4 5 6 7 8 Tme An observaton: c2 can be ncreased based on the concept of crtcal nstant!! Defntons: The utlzaton factor of a process τ s c /p. The fracton of CPU tme spent n executng τ. The utlzaton factor of a set of m processes s U = m = 1 For a gven prorty assgnment, a process set fully utlzes the processor f the prorty assgnment s feasble for the set and f any ncrease n the run tme of any processes n the set wll make the prorty assgnment nfeasble. c p
The achevable utlzaton factor (least upper bound of utlzaton factor) of a schedulng polcy Ua s a real number such that for any process set T, U(T ) <= Ua mples the schedulablty of the process set T. Theorem 3[LL73] For a set of two processes wth a fxed prorty assgnment, the achevable utlzaton factor s Proof. 2(2 1/2 1) U C1 = P2 P1 * floor(p2/p1) The mnmum U occurs when 0 P1 P2 P1 & P2 = 1 & = 2 1/ 2 1 nfeasble schedules U = { process sets } feasble schedules wthout CPU fully utlzaton feasble schedules wth CPU fully utlzaton Let T be nfeasble but U(T) < Ua Create a feasble schedule T from such that the CPU s fully utlzed U(T ) < U(T) < Ua
Theorem 4 [LL73] For a set of m processes wth a fxed prorty order and the restrcton that the rato between any two request perods s less than 2, the achevable utlzaton factor s Proof. m(2 1/m 1) c 1 c m-1 0 p 1 p 2 p m-1 p m Tme Each process n { 1,, m-1 } executes twce wthn P m. Theorem 5 [LL73] For a set of m processes wth fxed prorty order, the achevable utlzaton factor s m(2 1/m 1) p m Proof. 1 If p m = q * p + r, q > 1, p 1 p 1 p 1 r then p = q * p and ncrease c m tll the process set fully utlzes the processor agan. (c m <= c m + c * (q 1)). U < U + [( q -1) c pm] + c p c p Show that U s reduced! or U U + c ( q -1)[ 1 ( qp + r) ( 1 qp ) ] An observaton: If a process set are fully harmoncally related, U = 100%; otherwse U -> ln2 -> 70%! q-1
Earlest Deadlne Frst The Earlest Deadlne Frst algorthm (EDF) assgns processes prortes accordng to the deadlnes of ther current request. An EDF example: Two processes wth p1 = 2, p2 = 7, and c1 = 1, c2 = 1. 0 1 2 3 4 5 6 7 8 Tme For a set of processes scheduled accordng to some schedulng algorthm, we say that an overflow occurs at tme t f t s the deadlne of an unfulflled request. Theorem 6[LL73] When the EDF algorthm s used to schedule a set of processes on a processor, there s no processor dle tme pror to an overflow. Proof. dle overflow Tme Tme 0 Θ overflow should happen earler. Tme
Theorem 7[LL73] For a gven set of m processes, the EDF algorthm s feasble f and only f U = (c 1 /p 1 ) + (c 2 /p 2 ) + + (c m /p m ) <= 1 The achevable utlzaton factor of the EDF algorthm s 100%.The EDF algorthm s an optmal dynamc prorty schedulng polcy n the sense that a process set s schedulable f ts CPU utlzaton s no larger than 100%. The achevable utlzaton factor of the RMS algorthm s about ln2. The RMS algorthm s an optmal fxed prorty schedulng polcy n the sense that f a process set s schedulable by some fxed prorty schedulng algorthm, then t s schedulable by the RMS algorthm. Another thought of the above results? Theorem For a set of m processes wth fxed prorty order, the th process s schedulable f j = 1 Can we extend Theorem 7 n the same way? No! What s the mplcaton? What s the prorty of a process not reflectng ts mportance/crtcalty properly n the real world? How far can we go from here? c p j j ( 2 1 / 1)
Bran Damage! Theorem Gven a set of m processes, t s schedulable by some fxed prorty scheduler f U 1. Proof. a tme slce a tme slce. Tme For every tme slce, τ receve a share of s c /p. Wthn p, τ receves c /p!! Schedulng Overheads Context Swtchng Needed ether when a process s preempted by another process, or when a process completes ts executon! Stack Dscplne If process A preempts process B, process A must complete before process B can resume. A B If t s obeyed, charge the cost of preempton (context swtchng cost) once to the preemptng process! B A B
Is there any other optmal dynamc prorty schedulng algorthm besde the EDF algorthm? The least slack tme algorthm (LST), whch assgns processes prortes nversely proportonal to ther slack tmes s also optmal f context swtchng cost can be gnored [Mok83]. The slack tme of a process s d(t) - t - c(t). d(t)-t d(t) t c(t) Proof. Swap the schedulng unts of processes out of LST order. An LST example: c1 = c2 = 2, p1 = p2 = 4 s1=2 s2=2 S1=2 S2=1 S1=1 S2=1 1 2 2 1 0 1 2 3 4 Summary: Defntons Crtcal nstant and crtcal nterval. Utlzaton factor, achevable utlzaton factor, and least upper bound of utlzaton factor. RMS and EDF. The achevable utlzaton factor of RMS and EDF are ln2 and 100%, respectvely. The propertes and applcatons of RMS and EDF. Modelng of context swtchng cost, stack dscplne, and the propertes of least slack tme (LST).
Process Synchronzaton ktw@cse.ntu.edu.tw (Real-Tme and Embedded Systems Laboratory) Alternatve Approaches (1) Fnd and adopt a suboptmal algorthms. Note that a scheduler derved by a schedulng algorthm shall guarantee the schedulablty of a process set. A suboptmal algorthm seems only for off-lne computatons. (Hard Real-Tme constrants) (2)Put as many restrctons on the use of the communcaton prmtves as t s deemed reasonable for programmng realtme systems and hope that the restrcted schedulng problem can be effcently solved. Qs: In general, nterprocess coordnaton by means of semaphores s far too unstructured for real-tme analyss. Shall we have a more abstract-level language construct or more structed usages of communcaton prmtves? Shall we provde a language construct for excluson and synchronzaton?
Process Synchronzaton Processes Mght Share Non-Preemptble Resources or Have Precedence Constrants! Papers for dscussons: L. Sha, R. Rajkumar, J.P. Lehoczky, Prorty Inhertance Protocols: An Approach to Real-Tme Synchronzaton, IEEE Transactons on Computers, 1990. A.K. Mok, The Desgn of Real-Tme Programmng Systems Based on Process Models, IEEE Real-Tme Systems Symposum, Dec 1994. Process Synchronzaton Motvaton Can we fnd an effcent way to analyze the schedulablty of a process set (systematcally)? What knds of restrctons on the use of communcaton prmtves are needed so as to effcently solve the restrcted schedulng problem? How can we control the prorty nverson problem? The lengths of crtcal sectons mght be qute dfferent.
The Prorty Inverson Problem Prorty Inverson: A phenomenon where a hgher-prorty process s forced to wat for the executon of a lower-prorty process. Example: blockng vs preempton lock S unlock S 1 Blocked! Approaches: No preempton of crtcal sectons s allowed! =>They must be short! If preempton may be allowed, what prorty we should assgn the executon of a crtcal secton? 3 lock S lock S many ntermedate prorty processes may preempt 1 Prorty Inhertance Protocols: An Approach to Real-Tme Synchronzaton L. Sha, R. Rajkumar, J.P. Lehoczky, IEEE Transactons on Computers, 1990.
Notatons and Assumptons Notaton: Z, j, k : the kth crtcal secton n job (process) J guarded by semaphore S j. P(S ) and V(S ) are ndvsble operatons wat and sgnal respectvely on the bnary semaphore S. Assumptons: Each shared data structure s guarded by a bnary semaphore. No job attempts to lock a semaphore that has already been locked. Locks on semaphores wll be released before or at the end of a job. A fxed set of jobs executes on a processor. The Basc Prorty Inhertance Protocol Prorty-Drven Schedulng The process whch has the hghest prorty among the ready processes s assgned the processor. Synchronzaton Process must obtan the lock on the semaphore guardng a crtcal secton before enters the crtcal secton. If obtans the requred lock, enters the correspondng crtcal secton ; otherwse, s blocked and sad to be blocked by the process holds the lock on the correspondng semaphore. Once exts a crtcal secton, unlocks the correspondng semaphore and makes ts blocked processes ready. Prorty Inhertance If a process blocks hgher prorty processes, nherts the hghest prorty of the process blocked by Prorty nhertance s transtve.
Blockng Propertes 1 2 3 S 2 faces nhertance blockng S S lock S drect blockng Lemma 1 A semaphore S can be used to cause nhertance blockng to job J only f S s accessed by a job whch has a prorty lower than that of J and mght be accessed by a job whch has a prorty equal to or hgher than that of J. Propertes Lemma 2 A job J can be blocked by a lower prorty job J L only f J L has entered and remaned wthn a crtcal secton when J arrves. Lemma 3 A job J L can block a hgh prorty job J for at most the duraton of a crtcal secton regardless of the number of semaphores J and J L share.
Propertes Theorem 4 Under the basc prorty nhertance protocol, f there are n lower prorty jobs, a job J can be blocked for at most the duraton of n crtcal sectons. Lemma 5 A semaphore can be used by at most one lower prorty job s crtcal secton to block a hgher prorty process. Propertes Theorem 6 Under the basc prorty nhertance protocol, f there are m semaphores that can be used to block job J, then J can be blocked for at most the duraton of m crtcal sectons. Concerns: A chan of blockng s possble. A deadlock can be formed! 1 Request S 2 2 S2 3 S 1 Request S 1
The Prorty Celng Protocol The prorty celng of a semaphore s the prorty of the hghest prorty job that may lock the semaphore. The Basc Prorty Inhertance Protocol + Prorty Celng A job J may successfully lock a semaphore S f S s avalable, and the prorty of J s hgher than the hghest prorty celng of all semaphores currently locked by jobs other than J Prorty nhertance s transtve Example: Deadlock Avodance S 0 locked S 0 unlocked τ 0 τ 1 S 0 S 2 locked blocked by S 2 1 locked (attempt to lock S 1 ) S 1 S 1, S 2 S 2 unlocked S 1 S 1 unlocked S 1 locked S 1 unlocked τ 2 S 2 t 0 t 1 S 2 locked prorty nhertance S 2 S 2 S 1, S 2 S 2 t 2 t 3 t 4 t 5 t 6 t 7 t 8 Tme unlock S 2 and reset prorty
Example: Chan Blockng Avodance blocked by 2 (attempt to lock S 2 ) S 2 locked S 2 unlocked τ 0 τ 1 S 2 S 1 locked S blocked by 2 locked 2 (attempt to lock S 2 ) S 2 S 1, S 2 S 1 unlocked S 2 S 2 unlocked S 1 locked S 2 locked S 2 unlocked S 1 unlocked S τ 1 S 1 S 1, S 2 S 1, S 2 S 1 2 t 0 t 1 t 2 t 3 t 4 t 5 t 6 t 7 t 8 Tme Avodance blockng occurs! * Prce pad for deadlock avodance & chan blockng avodance! Propertes Lemma 7 A job J can be blocked by a lower prorty job J L only f the prorty of job J s no hgher than the hghest prorty celng of all the semaphores that are locked by job J L when J arrves. Lemma 8 Suppose that job J preempts job J j whch enters a crtcal secton. Under the prorty celng protocol, job J j cannot nhert a prorty level whch s hgher than or equal to that of J untl J completes.
Propertes Lemma 9 The prorty celng protocol prevents transtve blockngs. Proof. Follows Lemma 8. t 3 t 2 t 1 Theorem 10 The Prorty celng Protocol prevents deadlock. Proof. Lemma 9 shows that the number of jobs n the blockng cycle can only be 2. t2 t1 Propertes Lemma 11No job can be blocked for more than one crtcal secton of a lower prorty job J L. Proof. Follows Lemma 2 and Theorem 10. Theorem 12 No job can be blocked for more than one crtcal secton of any lower prorty job. Proof. Lemma 11 suggests that job J can only be blocked by n dfferent processes crtcal sectons f n > 1. The correctness of the proof them follows Lemma 7.
Propertes Theorem 15: A set of n perodc tasks under the prorty celng protocol can be scheduled by the rate monotonc algorthm f the followng condtons are satsfed:, 1 n, 1 cj c + B + ( 2 1/ 1) j= 1 pj p where B s the worst-case blockng tme for τ Proof. Consder B as an addtonal computaton requrement. Propertes B = Max crtcal secton β S = = τj β j, k { j j τj Pr( τ ) > Pr( τ ) & Max(Prorty - Celng( s)) Pr( τ )} s S { s Semaphore s s accesses by } j τj More accurate calculatons can be derved by consderng the relatonshp between crtcal sectons and ther correspondng semaphores.
Propertes Schedulablty Analyss Theorem 14 [Loc87] A set of n perodc tasks scheduled by the rate-monotonc algorthm wll meet all ther deadlnes (for all task phasngs) ff A, 1 n, mn ( k, l ) y j = 1 c j 1 lp = mn U ( k, l ) y j = 1 k j lp P k j P j lp lp k P j k 1 where P y = {(k, l) 1 k, l = 1,, P } k Propertes Schedulablty Analyss Another Thought: mn ( k, l ) y j = 1 c lp P j k j lp k 0 CPU requests of processes,, j are satsfed? 0 lp k P y = {(k, l) 1 k, l = 1,, P } k Check every request tme of processes,.e, lp k.
Propertes Schedulablty Analyss Theorem 16 A set of n perodc tasks usng the prorty celng protocol can be scheduled by the rate-monotonc algorthm for all task phasngs f A, 1 n, 1 + mn Pj lpk c B Uj + 1 k, l) y j= 1 lpk Pj lpk ( mn ( k, l ) y 1 j = 1 lp cj P k j + c + B lp k 0 Example Schedulablty Analyss block block 1 : C 1 = 40, P 1 = 100, B 1 = 20, U 1 = 0.4 2 : C 2 = 40, P 2 = 150, B 2 = 30, U 2 = 0.267 3 : C 3 = 100, P 3 = 350, B 3 = 0, U 3 = 0.286 Apply Theorem 15. U 1 + B 1 / P 1 = 0.4 + 0.2 = 0.6 < 1 U 2 + B 2 / P 2 + U 1 = 0.267 + 0.2 + 0.4 = 0.867 U = U 1 + U 2 + U 3 = 0.953 s far too large!
Example Schedulablty Analyss 1. 1 y 1 = {(1, 1)} Apply Theorem 16. C 1 + B 1 P 1?? => 40 + 20 < 100 schedulable! 2. 2 y 2 = {(1, 1), (2, 1)} C 1 + C 2 + B 2 P 1?? => 40 + 40 + 30 > 100 2C 1 + C 2 + B 2 P 2?? => 80 + 40 + 30 150 schedulable! 3. 3 y 3 = {(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3)} * B 3 = 0 C 1 + C 2 + C 3 P 1?? => 40 + 40 + 100 > 100 2C 1 + 2C 2 + C 3 2P 1?? => 80 + 80 + 100 > 200 3C 1 + 2C 2 + C 3 3P 1?? => 120 + 80 + 100 300 2C 1 + C 2 + C 3 P 2?? => 80 + 40 + 100 > 150 3C 1 + 2C 2 + C 3 2P 2?? => 120 + 80 + 100 300 schedulable! 4C 1 + 3C 2 + C 3 P 3?? => 160 + 120 + 100 > 350 Other Issues Implementaton Consderatons Prorty Inhertance Protocol (PIP) Prorty queues: one for each semaphore P( ) & V( ) operatons must support prorty nhertance Prorty Celng Protocol (PCP) A sngle prorty queue avodance blockng A lst of blocked semaphores and ther respectve owners and celngs
Other Issues Other synchronzaton mechansms Montor (used for schedulng mutual excluson) Defne celng for each montor. Operatons on montors are executed n an order complyng wth PCP. Server-Clent Model Server runs at the lowest prorty unless t s servcng or requested by some clents. PCP s mplemented as usual, when servers are treated as montors! Other Issues ADA rendezvous Prorty queues: one per entry call. When there are multple entres for a server task, the server task must select the hghest prorty task watng on one of the entres. PCP s mplemented as usual.
Summary Defntons Crtcal nstant, crtcal nterval, achevable utlzaton factor Harmonc base, harmonc chan, adaptve process optmal scheduler, optmal partton of a process set, deferrable server, pollng RMS & EDF are optmal fxed-prorty & dynamcprorty schedulers, respectvely. RMS s stable, but EDF has a hgh achevable utlzaton factor. Process sets wth a smaller harmonc base tend to be more schedulable and have better achevable utlzaton factor. Summary Consder the trade-off between the mnmzaton of the prorty nverson problem & the maxmzaton of the concurrency level of a system. Consder the deas behnd the schedulablty tests of PCP. After all, we only have lmted peces of knowledge n predctng the schedulablty of a system. However, we begn to understand and fnd out better ways n allocatng resources for processes!
Process Synchronzaton Processes Mght Share Non-Preemptble Resources or Have Precedence Constrants! Papers for dscussons: L. Sha, R. Rajkumar, J.P. Lehoczky, Prorty Inhertance Protocols: An Approach to Real-Tme Synchronzaton, IEEE Transactons on Computers, 1990. A.K. Mok, The Desgn of Real-Tme Programmng Systems Based on Process Models, IEEE Real-Tme Systems Symposum, Dec 1994. The Desgn of Real-Tme Programmng Systems Based on Process Models A.K. Mok, IEEE Real-Tme Systems Symposum, Dec 1994.
Defntons A totally on-lne scheduler makes schedulng decsons ndependent from a pror knowledge of the future request-tmes of the processes. A run-tme scheduler s the code for allocatng resources n response to requests generated at run tme, e.g., tmer or external devce nterrupts. A run-tme scheduler s clarvoyant f t has an oracle whch can predct wth absolute certanty the future request tmes of all processes. A run-tme scheduler s optmal f t always generates a feasble schedule whenever t s possble for a clarvoyant scheduler to do so. Remark: Check defntons n prevous transparences. Theorem 2 [Mok84] When there are mutual excluson constrants, t s mpossble to fnd a totally on-lne optmal run-tme scheduler. Proof. Consder two mutually exclusve processes: s : c s =1, d s =1, p s =4 p : c p =2, d p =4, p p =4 Select the request tme of s to fal any totally on-lne optmal run-tme scheduler. Let p occur at tme 0, and s occur at tme 1. The result can be trvally generalzed to the cases of multprocessor by creatng a perodc process wth c = p for each addtonal processor.
Theorem 4 [Mok84] The problem of decdng whether t s possble to schedule a set of perodc processes whch use semaphores only to enforce mutual excluson s NPhard. Proof. A 3-partton problem: A = {a 1, a 2,, a 3m }, B a postve nteger, and w 1, w 2,, w 3m be ntegral weghts of elements of A respectvely such that B/4 w B/2, and the sum of w s equal to mb. The decson s whether A can be parttoned nto m dsjont sets such that each of whch has weght B. Create 3m processes, where the th process has computaton tme w, and perod (mb+m), deadlne (mb+m). In addton, we create a process 3m+1 wth perod (B+1), deadlne 1, and run-tme 1. The Determnstc Rendezvous Model The Prmary Purpose: Establsh precedence constrants between the schedulng blocks of processes. Issues: Rendezvous overheads Charge t n the schedulng blocks rght before the rendezvous. => Rendezvous can be preempted! No mutual excluson! Compatblty of processes that rendezvous wth each another. 1. Perodc processes Havng perods beng an exact multple of each another. 2. Otherwse Server s the made ready whenever t s needed.
Example EDF s not optmal for the process model Example: C 11 * = C 12 = 1, d 1 = 3, p 1 = 5 1 : C 21 * = 1, C 22 * = 3, d 2 = p 2 = 10 3 : C 3 = 1, d = 9, 3 p 3 = 10 2 : c 11 c 12 c 11 c 12 1 rendezvous rendezvous c 21 c 22 2 c 3 3 EDF c 11 c 21 c 12 c 13 c 22 c 11 c 22 C 12 fals! c 11 c 3 c 21 C 12 fals! Deadlne Modfcaton A deadlne-modfcaton technology Consder the computatons performed n the nterval [0, L] Sort the schedulng blocks generated n [0, L] n a reverse topologcal order. Set the deadlne of the kth nstant of j to (k-1) * p + d Revse the deadlnes n reverse topologcal order by the formula: d mn d, d c s s ( { }) s = s s s : Run-tme scheduler repeats the revsed deadlnes every L tme unts (L s the longest perod among processes that rendezvous wth each another.)
Deadlne Modfcaton Lemma 5 [Mok 84] The feasblty of an nstance of the process model s not volated by the above revsng technology. The technology wll not volate or damage the precedence constrants nvolvng any two processes. check the prevous example! Theorem 6 [Mok 84] If a feasble schedule exsts for an nstance of a process model restrcted by rendezvous constrants, then t can be scheduled by EDF modfed to schedule the ready process whch s not blocked by a rendezvous and whch has the nearest dynamc deadlne. Remarks: A pseudo-polynomal-tme approach s presented! The Kernelzed Montor Model Idea: Processes are gven processor tme n an unnterruptble quantum, say q. If sporadc processes are of length multple of q, and each q s treated as crtcal sectons, the process model s reduced to an ndependent process schedulng wth the provson that a process may be nterrupted only after t has receved an nteger number of q. Sporadc processes are called montors. EDF s stll not optmal!
The Kernelzed Montor Model An EDF Example: q = 2 1 : c 1 = 2, d 1 = 2, p 1 = 5 2 : c 21 = c 22 = 2, d 2 = p 2 = 10 τ 1 c 1 c 1 τ 2 forbdden regon?! c 21 c 22 c 1 c 21 c 22 c 1 fal How to fnd the forbdden regons n the nterval [0, L] where L s the longest perod among the compatble processes? ( L = LCM(p ) ) 1. Each process s consdered as a chan of mn schedulng blocks: each of whch s of a quantum. 2. Revse request tmes and deadlnes of the block. requesttme revsng deadlne revsng (1) Sort the blocks n [0, L] n a forward topologcal order. (2) Intalze the request tme of the kth nstance of each mn schedulng block of T to (k-1)*p. (3) Revse the request tmes n forward topologcal order by the formula: r s = Max(r s, {r s + q : s s}) (4) Sort the blocks n [0, L] n a reverse topologcal order. (5) Intalze the deadlne of the kth nstance of each mn schedulng block of T to (k-1)* p + d (6) Revse the deadlnes n reverse order by the followng formula: d s = Max(d s, {d s q : s s })
3. Compute the set of forbdden regons n [0, L] n the followng way: (1) Sort the request tmes n a reverse chronologcal order and determne the forbdden regon assocated wth each request tme as follows: Intally, there are no forbdden regons. (2) For each request tme r s and any deadlne d for whch L d d s, let n r,d be the number of mn blocks whch must be scheduled n [r s, d]. (r s r s and d s d) If S r,d s the latest tme at whch the frst mn blocks must be scheduled, (stack blocks close to each anothor from d) (I) S r,d < r s System fals (II) S r,d < r s + q (S r,d q, r s ) s a forbdden regon. (III) otherwse, no acton s taken! *Complexty: O(n) for each request tme There are no more than n forbdden regons when n s the number of mn schedulng blocks generated n [0, L] W = {(x, y ) : y s the revsed request-tme of some mn schedulng block n [0, L], and no process should start pass x before y } The kernelzed montor scheduler: At any tme t, f t does not le n a forbdden regon, the scheduler allocates the next quantum to the ready process whch s not blocked by a rendezvous and has the earlest deadlne. If t s n a forbdden regon, the process s allowed to be dle untl the end of regon. Theorem 7[Mok 84] If a feasble schedule exsts for a process set wth rendezvous and montor communcaton prmtves, the kernelzed montor scheduler can schedule t.
A Related Theorem Theorem [Mok, et al. 87] If EDF s appled to schedule a set of ndependent perodc processes whose utlzaton factor s not more than 1, and the scheduler s subject to restrcton that every process must be allowed to run for at least q tme unts before t can be preempted, then no process wll ever mss ts deadlne by more than q 1 tme unts. Schedulablty Test: Add q 1 tme unts to the computaton tme of each process & check the total utlzaton factor. Applcatons: Put conflctng resource accesses n the q-tme-unt code for applcatons based on dataflow graphs. Overload Detecton for Sporadc Processes A sporadc process s one whose request tmes are not known a pror. Model a sporadc process by a par (p, c, d) where c = computaton tme p = mnmum separaton tme between two nstances. d = deadlne How should we set the separaton parameter p for a sporadc process? It s a tradeoff. If p s too bg, we rsk havng two more requests wthn p tme unts. If p s set too small, we mght have large gaps between requests and waste CPU capacty.
Overload Detecton for Sporadc Processes Is there an analyss method to evaluate the hypothess of the choce of tmng parameters on system relablty? Theorem 1 [Baruah, Mok, Roser, RTSS90] A set T of n sporadc processes s not feasble ( or schedulable by EDF) f ether n c (1) or, p (2) = 1 t : t < mn P + max u 1 u { d }, max { p d } s.t. T fals at or before t, where P = lcm{ p } Overload Detecton for Sporadc Processes Defne h R n ( t) = c t d max{0, p = 1 + 1} T s feasble ff t h R ( t ) t Lemma 3 [Baruah, Mok, Roser, RTSS90] The mnmum t that fals the above formula s the earlest tme that the EDF algorthm can report a falure.
Modelng of Sporadc Processes Lemma 3[Mok, RTSS84]: Suppose we replace every sporadc process = (c, p, d ) wth a perodc process = (c', p', d' ) wth c' = c, p' = mn(p, (d c + 1)), and d' = c. If the result set of all perodc processes can be successfully scheduled, then the orgnal set of processes can be scheduled wthout a pror knowledge of the request tmes of the sporadc processes. Proof. p' = d c + 1 1 c d Tme Modelng of Sporadc Processes In general, we can replace each sporadc process = (c, p, d ) wth a perodc process ' = (c', p', d' ) f the followng condtons are satsfed: [Mok, RTSS84] (1) d d' c; (2) c' = c; (3) p' d - d' + 1 Proof. p' = d d' + 1 1 d' d Tme
Summary Defntons: totally on-lne scheduler, clarvoyant scheduler, optmal run-tme scheduler crtcal regon compatblty, rendezvous model montor model The dffculty n fndng a totally on-lne optmal runtme scheduler. The NP-hard nature of the problem n schedulng a set of perodc processes that use semaphores to enforce mutual excluson. EDF wth the deadlne-revsng technology for the determnstc rendezvous model. EDF wth forbdden regons technology for the kernelzed montor model.