Solution Manual for Real Time System by Jane W. S. Liu Real Time System by Jane W. S. Liu (Pearson), the book builds on the student's bak!round in Operating System, Embedded System. "t o#ers tehni$ues for shedulin!, resoure aess ontrol, and #alidation that are, or are likely to be, %idely used in real time om&utin! and ommuniation systems. ah al!orithm, &rotool, or mehanism is defined by &seudo ode or sim&le rules that an ser#e as a startin! &oint of im&lementation. With fe% ee&tions, eah shedulin! al!orithm is aom&anied that your a&&liation %ill meet its real time re$uirement %hen shedulin! aordin! to the al!orithm.
ere, in net suessi#e &osts, " am !oin! to &ost solutions for the same Tet*book (Real Time System by Jane W. S. Liu). "f you find any diffiulty or %ants to su!!est anythin!, feel free to omment...+)
Link: http://targetiesnow.blogspot.in/p/solution-manual-for.html http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-w-s-liu_12.html
Real Time System by Jane W. S. Liu ha&ter -. Solution
/. -.+
0eause s&oradi 1obs may ha#e #aryin! release times and eeution times, the
&eriodi task model may be too inaurate and an lead to undue under utili2ation of the &roessor e#en %hen the inter times of 1obs bounded from and1obs their eeutions are bounded from abo#e. 3s anrelease eam&le, su&&ose %eare ha#e a stream of belo% s&oradi %hose inter release times are uniformly distributed from 4 to . Their eeution times are uniformly distributed from to -. a. What are the &arameters of the &eriodi task if %e %ere to use suh a task to model the stream5
a. What are the &arameters of the &eriodi task if %e %ere to use suh a task to model the stream5
Sol+ For the periodic task model we model a task using the lower bound on its period and the upper bound on its execution time (the worst case). n this case! the period! p " #! and the exeuction time! e " $.
b. om&are the utili2ation of the &eriodi task in &art (a) %ith the a#era!e utili2ation of the s&oradi 1ob stream. Sol+ The utili%ation o& a periodic task is its execution time di'ided by its period. n this case periodic " eperiodic*pperiodic " $*# " +.$$$$
,odeling the -ob as a stream o& periodic -obs! the execution time is a random 'ariable E uni&ormly distributed &rom to $ time units! and the period is a random 'ariable / uni&ormly distributed &rom # to . tili%ation is a random 'ariable that is a &unction o& E and /. n particular! sporadic " E*/. n general we can &ind the a'erage 'alue o& ! E01! we need to integrate u ⋅ &u(u)! the probability density &unction o& &rom 2in&inity to in&inity. 3ou can use the rules o& probability to determine & u(u) &rom &e(e) and &p(p). n this case! a&ter a bit more math than anticipated we &ind a.
+! 4 u* 5*6 2 *(6u5)! * 7 u 4 *# &u(u)"8 ! *#7u4$* #*(6u5) 2 6*6! $* 7 u 4 *$ +! u *7$ 9&ter integrating we &ind sporadic " E01 : +.5+. The utili%ation with the periodic task model is about $ ; more than i& we use the a'erage utili%ation.
Solution: liu.htm l
http://targetiesnow.blogspot.in/2013/10/real-time-system-by-jane-w-s-
Real Time System by Jane W. S. Liu ha&ter -.6 Solution
/.-.6+
onsider the real*time &ro!ram desribed by the &suedo ode belo%. 7ames of 1obs are in
itali.
3t 4 3M, start+ ha#e breakfast and !o to offie8 3t 9 3M, if there is lass, teach8 lse, help students8 When teach or help is done, eat_lunch8 :ntil 6 PM, sleep8 "f there is a seminar, "f to&i is interestin!, listen8 lse, read8 lse write in offie8 When seminar is o#er,attend soial hour8 discuss8 jog8 a) ;ra% a task !ra&h to a&ture the de&endenies amon! 1obs.
Sol+ The book was a bit 'ague on some points! so there will be much &lexibility in grading here. <'e seen these drawn a number o& di&&erent ways in di&&erent papers... The important part was to
capture the timing and dependecies and make clear which dependencies were conditional. The start time o& start! teach! and help is gi'en! so showing the &easible inter'al &or them is important. The only timing constraint is that sleep has to end at 5/,! though so the deadline is looser than what one would expect. =o timing constraints are gi'en &or eat_lunch! so they could be le&t out or (+ 9,! 5/,) would be reasonable. The deadline &or sleeping is gi'en! but no release time is gi'en &or sleep or eat_lunch! so +9, is the latest time we are bounded by. There is no mention o& any time a&ter sleep so we ha'e no in&ormation on what the deadlines o& any other tasks should be! unless we take >end o& day> to be the literal end o& day at midnight.
b) :se as many &reedene !ra&hs as needed to re&resent all the &ossible &aths of the &ro!ram. Sol+ ?lassical precedence graphs don
Solution s - liu_2.htm l
http://targetiesnow.blogspot.in/2013/10/real-time-system-by-jane-w-
Real Time System by Jane W. S. Liu ha&ter -.- Solution
/.-.-+
job_1 < job_2 denotes a &i&e+ The result &rodued by job_1 is inrementally onsumed
by job_2. (3s an eam&le, su&&ose that job_2 reads and dis&lay s one harater at a time as eah hand%ritten harater is reo!ni2ed and &laed in a buffer by job_1.) ;ra% a &reedene onstraint !ra&h to re&resent this &roduer*onsumer relation bet%een the 1obs.
Sol+ To show the pipeline relationship job_1 is broken into smaller -obs! one per character with each -ob depending on the preceding one. @ikewise! job_2 is broken up! but in addition to depending on the pre'ious character! each -ob in job_2 depending on the corresponding character &rom job_1.
Solution
http://targetiesnow.blogspot.in/2013/10/real-time-system-by-jane-ws - liu_!"0#.html$spref%f b
Real Time System by Jane W. S. Liu ha&ter -.= Solution
/.-.=+
;ra% a task !ra&h to re&resent the fli!ht ontrol system desribed in >i!ure *-.
a) 3ssume the &roduers and onsumers do not e&liitly synhroni2e (i.e., eah onsumer uses the latest result !enerated by eah of its &roduers but does not %ait for the om&letion of the &roduer.)
Sol+ /roducers and consumers do not synchroni%e! so there are no precedence constraints between producers and consumers. 3ou may ha'e drawn arrows to show precedence constraints between each -ob with the same release time! implied by the program listing. The whole schedule repeats e'ery A*6+ths " *$+th o& a second.
b) Re&eat &art (a), assumin! that &roduers and onsumers do synhroni2e. Sol+ The text says inner loops depend on outer loops and a'ionics tasks! output depends on inner loops. & you drew the constraints based on program order! only a &ew additional arcs need to be drawn because the program order causes the dependencies to be satis&ied.
Solution
s - liu_30&&.html
http://targetiesnow.blogspot.in/2013/10/real-time-system-by-jane-w-
Real Time System by Jane W. S. Liu ha&ter =. Solution
/.=.+
The feasible inter#al of eah 1ob in the &reedene !ra&h in fi!ure =P* is !i#en net to its name. The eeution time of all 1obs are e$ual to .
a) >ind the effeti#e release times and deadlines of the 1obs in the &reendene !ra&h in >i!ure =P* .
Real Time System by Jane W. S. Liu Chapter 4.1 Solution The feasible inter#al of eah 1ob in the &reedene !ra&h in fi!ure =P* is !i#en net to /.=.+ its name. The eeution time of all 1obs are e$ual to .
a) >ind the effeti#e release times and deadlines of the 1obs in the &reendene !ra&h in >i!ure =P* . Sol+
b) >ind an ;> shedule of the 1obs. Sol+
) 3 1ob is said to be at le#el i if the len!th of the lon!est &ath from the 1ob to 1obs that ha#e no suessors is i. So, 1obs J-, J? and J4 are at le#el 9, 1obs J6, J@ and JA are at le#el , and so on. Su&&ose that the &riorities of the 1obs are assi!ned based on their le#els, the hei!her the le#el, the hi!her the &riority. >ind a &riority*dri#e shedule of the 1obs in >i!ure =P* aordin! to this &riority assi!nment. Sol+
Explanation B is the only -ob released at t"+! so it goes &irst. •
•
9t t"! B5! BC! and BD ha'e been released. B C has a le'el o& $! so it goes &irst.
•
9t t"5! BCis done. BD has the next highest le'el (5)! so it goes next.
•
9t t"$! BD is done. B$! B8! B6! and B# are released. B8 has the next highest le'el (5)! so it
runs. •
9t t"C! B8 is done. Either B5 or B6 could run because both ha'e a le'el o& and both ha'e had their precedence contraints met. 9t this point B5 has already missed its deadline... 9t t"8! either B 5 or B6! whiche'er was run at t"C! is done. The one that was not pre'iously run gets to run. There are no more le'el -obs. •
9t t"A! B$! BA! and B# are all eligible to run and are all at le'el +. They can run in any order occording to this scheduling algorithm. •
•
B5 and B$ miss their deadlines. This is not an optimal scheduling algorithm.
Solution
s - liu_1'#.htm l
http://targetiesnow.blogspot.in/2013/10/real-time-system-by-jane-w-
Real Time System by Jane W. S. Liu ha&ter =.6 Solution
/.=.6+
The eeution times of the 1obs in the &reedene !ra&h in fi!ure =P*6 are all e$ual to
, and their release times are idential. Bi#e a non &reem&ti#e o&timal shedule that minimi2es the om&letion time of all 1obs on three &roessors. ;esribe briefly the al!orithm you used to find the shedule.
Sol+ Execution time o& all -obs eual to . Release times are identical! non preempti'e optimal
solution
Solution
http://targetiesnow.blogspot.in/2013/10/real-time-system-by-jane-ws - liu_"0!2.htm l
Real Time System by Jane W. S. Liu ha&ter =.= Solution
/.=.=+
onsider a system that has fi#e &eriodi tasks, 3, 0, , ;, and , and three &roessors
P, P 6, P -. The &eriods of 3, 0, and are 6 and their eeution times are e$ual to . The &eriods of ; and are A and their eeution times are ?. The &hase of e#ery task is 9, that is, the first 1ob of the task is released at time 9. The relati#e deadline of e#ery task is e$ual to its &eriod. a) Sho% that if the tasks are sheduled dynamially on three &roessors aordin! to the LST al!orithm, some 1obs in the system annot meet their deadlines. a) Sho% that if the tasks are sheduled dynamially on three &roessors aordin! to the LST al!orithm, some 1obs in the system annot meet their deadlines. Sol+
9t t"+! 9! ! and ? ha'e time unit o& slack. G and E each ha'e a slack o& 5! so 9! ! and ? run &irst. 9t t"! 9! ! and ? are done running and the slack o& G and E is 5! so G and E both get to run. 9t t"5! 9! ! and ? are released again. Their slack is ! as are the slacks o& G and E. 9ssuming that once a -ob starts running on a processor! it cannot change processors! G and E will run round2robin on two processors with two o& 9! ! and ? with the third running alone. y time t"$! 9! ! and ? will ha'e completed! and G and E will ha'e completed one time unit o& work. 9t t"C! new -obs in 9! ! and ? are released with a slack o& ! but G and E ha'e + slack. G and E run on two processors and 9! ! and ? run round2robin on the third. 9t t"8.8 the 9! ! and ?
ind a feasible shedule of the fi#e tasks on three &roessors. Sol+
Sol+
Solution
s - liu_1!&2.html
http://targetiesnow.blogspot.in/2013/10/real-time-system-by-jane-w-
Real Time System by Jane W. S. Liu ha&ter =.@ Solution
/.=.@+
3 system ontains nine non*&reem&table 1obs named Ji, for i C , 6, ..., 4. Their
eeution times are -, 6, 6, 6, =, =, =, =, and 4, res&eti#ely, their release times are e$ual to 9, and their deadlines are 6. J is the immediate &redeessor of J 4, and J= is the immediate &redeessor of J@, J ?, JD, and JA. There are no other &reedene onstraints. >or all the 1obs, J i has a hi!her &riority than J k if i E k. a) ;ra% the &reedene !ra&h of the 1obs. Sol+
b) an the 1obs meet their deadlines if they are sheduled on three &roessors5 &lain your ans%er.
Sol+ 9ll -obs meet their deadline.
) an the 1obs meet their deadlines if %e make them &reem&table and shedule them &reem&ti#ely5 &lain your ans%er. Sol+ Bob B# does not meet its deadline.
d) an the 1obs meet their deadlines if they are sheduled non&reem&ti#ely on four &roessors5 &lain your ans%er. Sol+ Bob B# does not meet its deadline.
e) Su&&ose that due to an im&ro#ement of the three &roessors, the eeution time of e#ery 1ob is redued by . an the 1obs meet their deadlines5 &lain your ans%er. Sol+ Bob B# does not meet its deadline.
Solution
http://targetiesnow.blogspot.in/2013/10/real-time-system-by-jane-ws - liu_&""'.htm l
Real Time System by Jane W. S. Liu ha&ter =.D Solution
/.=.D+
onsider the set of 1obs in >i!ure =*-. Su&&ose that the 1obs ha#e idential eeution
time. What maimum eeution time an the 1obs ha#e and still an be feasible shedulin! on
one &roessor5 &lain your ans%er.
Sol+ Bobs with their e&&ecti'e release t ime and deadline are
B (5!6) B5 (+!D) B$ (5!6) BC (C!#) B8 (5!6) BA (C!5+) etween 5 to #! &our -obs need to be &it. Hence! maximum execution time o& each -ob is .D8
BD (A!5)
Solution
http://targetiesnow.blogspot.in/2013/10/real-time-system-by-jane-ws - liu_3'1.htm l
Real Time System by Jane W. S. Liu ha&ter @.(a)(b) Solution
/.@.+
ah of the follo%in! systems of &eriodi tasks is sheduled and eeuted aordin! to
a yli shedule. >or eah system, hoose an a&&ro&riate frame si2e. Preem&tions are allo%ed, but the number of &reem&tion should be ke&t small. a) (?, ), (9, 6), and (A, 6) Sol+
The &rame si%e has to meet all three criteria discussed in t he chapter.
1.
& I max(ei)! 7 i 7 n
&I5 & di'ides at least one o& the periods e'enly & ∈ J5! $! 8! A! #! +! 6K 2.
3.
5& 2 gdc(&! pi) 7 Gi! 7 i 7 n
&"5 5 L 5 2 gcd(5! A) " 5 2 5 " + 7 5 5 L 5 2 gcd(5! +) " 5 2 5 " + 7 8 5 L 5 2 gcd(5! 6) " 5 2 5 " + 7 8 &"$ 5 L $ 2 gcd($! A) " A 2 $ " $ M 5 &"8 5 L 8 2 gcd(8! A) " + 2 " # M 5 &"A 5 L A 2 gcd(A! A) " 5 2 A " A M 5 &"# 5 L # 2 gcd(#! A) " 6 2 $ " 8 M 5 & " 6 5 L + 2 gcd(+! A) " 5+ 2 5 " 6 M 5 & " 6 5 L 6 2 gcd(6! A) " $A 2 A " $+ M 5 The only &rame si%e that works &or this set o& tasks is & " 5.
b) (A, ), (@, -), (69, =), and (66, ?)
Sol+ The &rame si%e has to meet all three criteria discussed in the chapter.
1.
& I max(ei)! 7 i 7 n
&IA & di'ides at least one o& the periods e'enly & ∈ J! 5! $! C! 8! 6! +! ! 8! 5+! 55K 2.
3.
5& 2 gdc(&! pi) 7 Gi! 7 i 7 n
&"6 5 L 6 2 gcd(6! 6) " A 2 6 " 6 7 6 5 L 6 2 gcd(6! 8) " A 2 " 8 7 8 5 L 6 2 gcd(6! 5+) " A 2 C " 5 7 5+ 5 L 6 2 gcd(6! 55) " A 2 5 " C 7 55 & " + 5 L + 2 gcd(+! 6) " 5+ 2 5 " 6 M 6 & " 5 L 2 gcd(! 6) " 55 2 " 5 M 6 & " 8 5 L 8 2 gcd(8! 6) " $+ 2 " 5# M 6 & " 5+ 5 L 5+ 2 gcd(5+! 6) " C+ 2 C " $A M 5 & " 55 5 L 55 2 gcd(55! 6) " CC 2 5 " C5 M 5 The only &rame si%e that works &or this set o& tasks is & " 6.
Clock-driven Cyclic Scheduler Since the parameters o! all "obs #ith hard deadlines are kno#n can construct a static cyclic schedule in advance $ %rocessor time allocated to a "ob e&uals its ma'imum e'ecution time $ Scheduler dispatches "obs accordin( to the static schedule) repeatin( each hyperperiod $ Static schedule (uarantees that each "ob completes by its deadline *o "ob overruns ⇒ all deadlines are met Schedule calculated o!!-line ⇒ can use comple' al(orithms $ Run-time o! the schedulin( al(orithm irrelevant $ Can search !or a schedule that optimi+es some characteristic o! the system e.(. a schedule #here the idle periods are nearly periodic, accommodatin( aperiodic "obs
Structured Cyclic Schedules rbitrary table-driven cyclic schedules !le'ible) but ine!!icient $ Relies on accurate timer interrupts) based on e'ecution times o! tasks $ i(h schedulin( overhead /asier to implement i! structure imposed0 $ ake schedulin( decisions at periodic intervals 2!rames3 o! len(th ! $ /'ecute a !i'ed list o! "obs #ith each !rame) disallo#in( pre-emption e'cept at !rame boundaries $ Re&uire phase o! each periodic task to be a non-ne(ative inte(er multiple o! the !rame si+e The !irst "ob o! every task is released at the be(innin( o! a !rame 5 k⋅! #here k is a non-ne(ative inte(er 6ives t#o bene!its0 $ Scheduler can easily check !or overruns and missed deadlines at the end o! each !rame $ Can use a periodic clock interrupt) rather than pro(rammable timer
Solution
http://targetiesnow.blogspot.in/2013/10/real-time-system-by-jane-ws - liu_#!##.htm l
Real Time System by Jane W. S. Liu ha&ter @.()(d) Solution
/@.+
ah of the follo%in! systems of &eriodi tasks is sheduled and eeuted aordin! to a
yli shedule. >or eah system, hoose an a&&ro&riate frame si2e. Preem&tions are allo%ed, but the number of &reem&tions should be ke&t small. ) (=, 9.@), (@, .9), (9, 6), and (6=, 4)
) (=, 9.@), (@, .9), (9, 6), and (6=, 4) Sol+ The &rame si%e has to meet all three criteria di scussed in the chapter. 1. & I max(ei)! 7 i 7 n &I# 2. & di'ides at least one o& the periods e'enly & ∈ J5! $! C! 8! A! 6! +! 5! 5CK 3. 5& 2 gdc(&! pi) 7 Gi! 7 i 7 n & " + 5 L + 2 gcd(+! C) " 5+ 2 5 " 6 M C & " 5 5 L 5 2 gcd(5! C) " 5C 2 C " 5+ M C & " 5C 5 L 5C 2 gcd(5C! C) " C6 2 C " CC M C =one o& the possible &rame si%es becuase e C " # is too long. Ne ha'e to split TC into two smaller tasks. First try e C! " C! and eC!5 " 8. 1. & I max(ei)! 7 i 7 n &I8 2. & di'ides at least one o& the periods e'enly & ∈ J5! $! C! 8! A! 6! +! 5! 5CK 3. 5& 2 gdc(&! pi) 7 Gi! 7 i 7 n &"8 5 L 8 2 gcd(8! C) " + 2 " # M C
9 &rame si%e o& 8 is still too big! as is a &rame si%e o& C.8. Ne cannot make the &rame si%e any smaller unless we break up the taks into smaller pi eces. Try di'iding TC into three eual si%ed pieces with eC " $. 1. & I max(ei)! 7 i 7 n &I$ 2. & di'ides at least one o& the periods e'enly & ∈ J5! $! C! 8! A! 6! +! 5! 5CK 3. 5& 2 gdc(&! pi) 7 Gi! 7 i 7 n &"$ 5 L $ 2 gcd($! C) " A 2 " 8 M C E'en three is too big. Ne need to break up TC &urther! try &our tasks with execution time 5 and one with execution time . 1. & I max(ei)! 7 i 7 n &I5 2. & di'ides at least one o& the periods e'enly & ∈ J5! $! C! 8! A! 6! +! 5! 5CK 3. 5& 2 gdc(&! pi) 7 Gi! 7 i 7 n &"5 5 L 5 2 gcd(5! C) " C 2 5 " 5 7 C 5 L 5 2 gcd(5! 8) " C 2 " $ 7 C 5 L 5 2 gcd(5! +) " C 2 5 " 5 7 C 5 L 5 2 gcd(5! 5C) " C 2 5 " 5 7 C Nith this set o& tasks & " 5 works.
d) (@, 9.), (D, .9), (6, ?), and (=@, 4) Sol+ The &rame si%e has to meet all three criteria di scussed in the chapter. & I max(ei)! 7 i 7 n &I# The smallest period is 8! which is less than the longest execution time. Ne cannot ha'e a &rame si%e larger than the period! so at this point we know we ha'e to split the (C8! #) task and the (5! A) task. Splitting (C8! #) into two tasks does not l ea'e many &rame si%e choices. Try (C8! #) "M (C8! $)! (C8! $)! (C8! $) and (5! A) "M (5! $)! (5! $) &I $ 1.
& di'ides at least one o& the periods e'enly & ∈ J! 5! $! C! 8! A! D! #! 5! 8! C8K 2.
3.
5& 2 gdc(&! pi) 7 Gi! 7 i 7 n
&"$ 5 L $ 2 gcd($! 8) " A 2 " 8 7 8 5 L $ 2 gcd($! D) " A 2 " 8 7 D 5 L $ 2 gcd($! 5) " A 2 $ " $ 7 5 5 L $ 2 gcd($! C8) " A 2 $ " $ 7 C8 &"C 5 L C 2 gcd(C! 8) " 6 2 " D M 8 &"8 5 L 8 2 gcd(8! 8) " + 2 8 " 8 7 8
5 L 8 2 gcd(8! D) " + 2 " # M D The only &rame si%e that works &or this set o& tasks is & " $ (assuming the last two tasks are split as described abo'e.)
Scheduling 9periodic Bobs F 3&eriodi 1obs are sheduled in the bak!round after all 1obs %ith hard deadlines sheduled in eah frame ha#e om&leted G ;elays eeution of a&eriodi 1obs in &referene to &eriodi 1obs G o%e#er, note that there is often no ad#anta!e to om&letin! a hard real*time 1ob early, and sine an a&eriodi 1ob is released due to an e#ent, the sooner suh a 1ob om&letes, the more res&onsi#e the system F ene, minimi2in! res&onse times for a&eri odi 1obs is ty&ially a desi!n !oal of real*time shedulers
Slack Stealing F Periodi 1obs sheduled in frames that end before their deadline8 there may be some slak time in the frame after the &eriodi 1ob om&letes F Sine %e kno% the eeuti on time of &eriodi 1obs, an mo#e the slak time to the start of the frame, runnin! the &eriodi 1obs 1ust in time to meet their deadline F eute a&eriodi 1obs in the slak time, ahead of &eriodi 1obs G The yli eeu ti#e kee&s trak of the slak left in eah frame as the a&eriodi 1obs eeute, &reem&ts them to start the &eriodi 1obs %hen there is no more slak G 3s lon! as there is slak remainin! in a frame, the yli eeuti#e returns to eamine the a&eriodi 1ob $ueue after eah slie om&letes F Redues res&onse time for a&eriodi 1obs, but re$uires aurate timers
Solution
s- liu_30&.html
http://targetiesnow.blogspot.in/2013/10/real-time-system-by-jane-w-
Real Time System by Jane W. S. Liu ha&ter @.(e)(f) Solution
/.@.+
ah of the follo%in! systems of &eriodi tasks is sheduled and eeuted aordin! to
a yli shedule. >or eah system, hoose an a&&ro&riate frame si2e. Preem&tions are allo%ed, but the number of &reem&tions should be ke&t small.
e) (@, 9.), (D, .9), (6, ?), and (=@, 4)
e) ( @, 9.), (D, .9), (6, ?), and (=@, 4) Sol+ The &rame si%e has to meet all three criteria di scussed in the chapter.
& I max(ei)! 7 i 7 n &I# The smallest period is 8! which is less than the longest execution time. Ne cannot ha'e a &rame si%e larger than the period! so at this point we know we ha'e to split the (C8! #) task and t he (5! A) task. Splitting (C8! #) into two tasks does not lea'e many &rame si%e choices. Try (C8! #) "M (C8! $)! (C8! $)! (C8! $) and (5! A) "M (5! $)! (5! $) &I $ 2. & di'ides at least one o& the periods e'enly & ∈ J! 5! $! C! 8! A! D! #! 5! 8! C8K 3. 5& 2 gdc(&! pi) 7 Gi! 7 i 7 n &"$ 5 L $ 2 gcd($! 8) " A 2 " 8 7 8 5 L $ 2 gcd($! D) " A 2 " 8 7 D 5 L $ 2 gcd($! 5) " A 2 $ " $ 7 5 5 L $ 2 gcd($! C8) " A 2 $ " $ 7 C8 &"C 5 L C 2 gcd(C! 8) " 6 2 " D M 8 &"8 5 L 8 2 gcd(8! 8) " + 2 8 " 8 7 8 5 L 8 2 gcd(8! D) " + 2 " # M D The only &rame si%e that works &or this set o& tasks is & " $ (assuming the last two tasks are split as described abo'e.) 1.
f) (D, @, , @), (4, ), (6, -), and (9.@, 6-, D, 6) Sol+ The &rame si%e has to meet all three criteria di scussed in the chapter. & I max(ei)! 7 i 7 n &ID The smallest period is 8! which is less than the longest execution time. Ne cannot ha'e a &rame si%e larger than the period! so at this point we know we ha'e to split the (+.8! 5$! D! 5) task. Splitting it into t wo tasks does not work (try it! to see). Split the long task into three (+.8! 5$! $! 5)! (+.8! 5$! $! 5)! and (+.8! 5$! 5! 5) &I $ 1.
& di'ides at least one o& the periods e'enly & ∈ J! 5! $! C! 8! A! #! 5! 5$K 2.
3.
5& 2 gdc(&! pi) 7 Gi! 7 i 7 n
&"$ 5 L $ 2 gcd($! 8) " A 2 " 8 7 8 5 L $ 2 gcd($! #) " A 2 $ " $ 7 # 5 L $ 2 gcd($! 5) " A 2 $ " $ 7 5 5 L $ 2 gcd($! 5$) " A 2 " 8 7 5 &"C 5 L C 2 gcd(C! 8) " 6 2 " D M 8 &"8 5 L 8 2 gcd(8! 8) " + 2 8 " 8 7 8
5 L 8 2 gcd(8! #) " + 2 " # 7 # 5 L 8 2 gcd(8! 5) " + 2 " # 7 5 5 L 8 2 gcd(8! 5$) " + 2 " # 7 5 Either & " $ or & " 8 may work! assuming the last two tasks are split as described abo'e. Ne need to make a schedule to 'eri&y the tasks can be scheduled with those &rame si%es.
Scheduling Sporadic Jobs We assumed there #ere no sporadic "obs Sporadic "obs have hard deadlines) release and e'ecution times that are not kno#n a priori $ ence) a clock-driven scheduler cannot (uarantee a priori that sporadic "obs complete in time o#ever) scheduler can determine i! a sporadic "ob is schedulable #hen it arrives $ %er!orm an acceptance test to check #hether the ne#ly released sporadic "ob can be !easibly scheduled #ith all the "obs in the system at that time $ 7! there is su!!icient slack time in the !rames be!ore the ne# "ob8s deadline) the ne# sporadic "ob is accepted, other#ise) it is re"ected Can be determined that a ne# sporadic "ob cannot be handled as soon as that "ob is released, earliest possible re"ection $ 7! more than one spora dic "ob arrives at once) they should be &ueued !or acceptance in /9: order
Practical Considerations andlin( overruns0 $ Jobs are scheduled based on ma'imum e'ecution time) but !ailures mi(ht cause overrun $ robust system #ill handle this by either0 13 killin( the "ob and startin( an error recovery task, or ;3 preemptin( the "ob and schedulin( the remainder as an aperiodic "ob 9epends on use!ulness o! late results) dependencies bet#een "obs) etc. ode chan(es0 $ cyclic sched uler needs to kno# all param eters o! real-time "obs a priori $ S#itchin( bet#een modes o! operation implies recon!i(urin( the scheduler and brin(in( in the code
Solution
s - liu_'3.htm l
http://targetiesnow.blogspot.in/2013/10/real-time-system-by-jane-w-
Real Time System by Jane W. S. Liu ha&ter @.6 Solution
/[email protected]+
3 system uses the yli ;> al!orithm to shedule s&oradi 1obs. The yli shedule of
&eriodi tasks in the system uses a frame si2e of @, and a ma1or yle ontaints ? frames. Su&ose that the initial amounts of slak time in the frames are , 9.@, 9.@, 9.@, , and . a. Su&&ose that a s&oradi 1ob S(6-, ) arri#es in frame , s&oradi 1obs S 6(?, 9.A) and S-(69, 9.@) arri#e in frame 6. "n %hih frame are the ae&ted s&oradi 1obs sheduled5 a.
Su&&ose that a s&oradi 1ob S(6-, ) arri#es in frame , s&oradi 1obs S 6(?, 9.A) and S-(69, 9.@) arri#e in frame 6. "n %hih frame are the ae&ted s&oradi 1obs sheduled5
Sol S(5$! ) Since S arri'es in &rame ! scheduling decisions about it are made at the start o& &rame 5. Frame 5 has a slack o& +.8! as does &rame $. Frame $ ends at t"8 which is well
be&ore S
Sol+ ?all the aperiodic -ob 9. Nhen all the periodic -obs complete at the end o& &rame ! the scheduler will let 9 execute until the start o& &rame 5! time unit later. Frames 5! $! and C ha'e no slack because S and S$! &rom part (a)! consume all o& it. The scheduler runs 9 in the slack at the ends o& &rames 8 and A. 9 completes at t"$+! the end o& &rame A.
Pro and Cons of Clock Driven Scheduling Simplicity $/asy e'tension o! !rame based decision to event driven $9ecision made at clock ticks /vents are &ueued Time driven pollin( ard to maintain and modi!y :i'ed release time and must be kno#n in advance
Solution liu_2"0!.html
http://targetiesnow.blogspot.in/2013/10/real-time-system-by-jane-w-s-
Real Time System by Jane W. S. Liu ha&ter @.- Solution
/[email protected]+ ;ra% a net%ork flo% !ra&h that %e an use to find a &reem&ti#e yli shedule of the &eriodi tasks T C (-,D,)8 T6 C (=,)8 T- C (?,6.=,A).
Sol+
1.
& I max(e i)! 7 i 7 n
& I 5.C & di'ides at least one o& the periods e'enly & ∈ J$! C! A!5K 2.
3.
/i
5& 2 gdc(&! pi) 7 Gi! 7 i 7 n Gi
&"$
&"C
&"A
$
D
$
D
#
C
C
8
C
+
A
6
$
A
A
Hence &or & " C! =etwork &low graph is2
T$ can
3ssum&tions for lok*dri#en shedulin! F lok*dri#en shedulin! a&&liable to deterministi systems F 3 restrited &eriodi task model+ G The &arameters of all &eriodi tasks are kno%n a &riori G >or eah mode of o&eration, system has a fied number, n, &eriodi tasks F >or task Ti eah 1ob Ji,k is ready for eeutio n at its release time ri,k and is released &i units of time after the &re#ious 1ob in Ti suh that ri,k C ri,k* H &i F Iariations in the inter*release times of 1obs in a &eriodi task are ne!li!ible G 3&eriodi 1obs may eist F 3ssume that the system maintains a sin!le $ueue for a&eriodi 1obs F Whene#er the &roe ssor is a#ail able for a&er iodi 1obs, the 1ob at the head of this $ueue is eeuted G There are no s&oradi 1obs
7otation for lok*dri#en shedulin! F The =*tu&le Ti C (i, &i, ei, ;i) refers to a &eriodi task Ti %ith &hase i, &eriod &i, eeution time ei, and relati#e deadline ;i G ;efault &hase of Ti is i C 9, default relati#e deadline is the &eriod ;i C &i.
Kmit elements of the tu&le that ha#e default #alues
The lok*dri#en a&&roah has many ad#anta!es+ * one&tual sim&liity8 * %e an take into aount om&le de&endenies, ommuniation delays, and resoure ontentions amon! 1obs in the hoie and onstrution of the stati shedule8 * stati shedule stored in a table8 han!e table to han!e o&eration mode8 * no need for onurreny ontrol and synhroni2ation mehanisms8 * ontet s%ith o#erhead an be ke&t lo% %ith lar!e frame si2es. "t is &ossible to further sim&lif y lok*dri#en shedulin! * s&oradi and a&eriodi 1obs may also be time*tri!!ered (interru&ts in res&onse to eternal e#ents are $ueued and &olled &eriodially)8 * the &eriods may be hosen to be multi&les of the frame si2e. * asy to #alidate, test and ertify (by ehausti#e simulation and testin!). * Many traditional real*time a&&liations use lok*dri#en shedules. * This a&&roah is suited for systems (e.!. small embedded ontrollers) %hih are rarely modified one built.
Solution
http://targetiesnow.blogspot.in/2013/10/real-time-system-by-jane-w-s-
liu_""3'.html
Real Time System by Jane W. S. Liu ha&ter @.= Solution
/.@.=+ 3 system ontains the follo%in! &eriodi tasks+T C (@,)8 T6 C (D,,4)8 T- C (9,-) and T= C (-@,D).
"f the frame si2e onstraint (@*) is i!nored, %hat are the &ossible frame si2es 5
Sol+
1.
/i
& I max(ei)! 7 i 7 n This step is ignored! here. 2. & di'ides at least one o& the periods e'enly & ∈ J5! 8! D! +! C! $8K 3. 5& 2 gdc(&! p i) 7 Gi! 7 i 7 n Gi &"5 &"8 &"D & " + & " C
& " $8
8
8
$
8
$(x)
8(x)
D
#
$
#
D
#(x)
5(x)
+
+
5
8
$(x)
+
5A(x)
$8
$8
$
8
D
8
5D(x)
5+
A8(x) A$(x) A8(x) $8(x)
Cyclic scheduling: frame size
9ecision points at re(ular intervals2!rames3, Within a !rame the processor may be idle to accommodate aperiodic "obs The !irst "ob o! every task is released at the be(innin( o! some !rame o# to determine the !rame si+e ! = The !ollo#in( > constraints should be satis!ied0 1. ! ? ma'2ei3
2!or 1 @ i @ n3 2n tasks3
each "ob may start and complete #ithin one !rame0 no "ob is preempted ;. Api
2!or at least one i3
to keep the cyclic schedule short) ! must divide the hyperperiod , this is true i! ! divides at least one pi >. ;! $ (cd2pi)!3 @ 9i 2!or 1 @ i @ n3 to have at least one #hole !rame bet#een the release time and the deadline o! every "ob 2so the "ob can be !easibly scheduled in that !rame3
Constructin( a cyclic schedule 9esi(n steps and decisions to consider in the process o! constructin( a cyclic schedule0 Ddetermine the hyperperiod ) Ddetermine the total utili+ation E 2i! F1 schedule is un!easible3) Dchoose a !rame si+e that meets the constraints) Dpartition "obs into slices) i! necessary)
Dplace slices in the !rames.
The clock-driven approach has many disadvanta(es0 - brittle0 chan( es in e'ecution time or addition o! a task o!ten re&uire a ne# schedule to be constructed, - release times must be !i'ed 2this is not re&uired in priority-driven systems3, - all combinations o! periodic tasks that mi(ht e'ecute at the same time must be kno#n a priori0 it is not possible to recon!i(ure the system on line 2priority-driven systems do not have this restriction3, - not suitable !or many systems that contain both hard and so!t real- time applications0 in the clockdriven systems previously discussed) aperiodic and sporadic "obs #ere scheduled in a priority driven manner 2/9:3.
Solution
http://targetiesnow.blogspot.in/2013/10/real-time-system-by-jane-w-s-
liu_!'3".html
Real Time System by Jane W. S. Liu ha&ter ?.= Solution
/.?.=+ 3 system T
ontains for &eriodi tasks, (A, ), (@, -), (69, =), and (66, ?). "ts total
utili2ation is 9.A9. onstrut the initial se!ment in the time inter#al (9, @9) of a rate*monotoni shedule of the system. Sol+ The scheduling will be as2
Schedulability Test for RMA n important problem that is addressed durin( the desi(n o! a uniprocessor-based real-time system is to check #hether a set o! periodic real-time tasks can !easibly be scheduled under R. Schedulability o! a task set under R can be determined !rom a kno#led(e o! the #orst-case e'ecution times and periods o! the tasks. pertinent &uestion at this point is ho# can a system developer determine the #orst-case e'ecution time o! a task even be!ore the system is developed. The #orst-case e'ecution times are usually determined e'perimentally or throu(h simulation studies. The !ollo#in( are some important criteria that can be used to check the schedulability o! a set o! tasks set under R.
Necessary Condition set o! periodic real-time tasks #ould not be R schedulable unless they satis!y the !ollo#in( necessary condition0 i5 Gei < pi 5 Gui @ 1 #here ei is the #orst case e'ecution time and pi is the period o! the task Ti) n is the number o! tasks to be scheduled) and ui is the C%E utili+ation due to the task Ti. This test simply e'presses the !act that the total C%E utili+ation due to all the tasks in the task set should be less than 1.
Sufficient Condition The derivation o! the su!!iciency condition !or R schedulability is an important result and #as obtained by Liu and Layland in 1HI>. !ormal derivation o! the Liu and Layland8s results !rom !irst principles is beyond the scope o! this discussion. We #ould subse&uently re!er to the su!!iciency as the Liu and Layland8s condition. set o! n real-time periodic tasks are schedulable under R) i! i5Gui @ n2;1.4<;.13 #here ui is the utili+ation due to task Ti. Let us no# e'amine the implications o! this result. 7! a set o! tasks satis!ies the su!!icient condition) then it is (uaranteed that the set o! tasks #ould be R schedulable.
Solution liu_131.htm l
http://targetiesnow.blogspot.in/2013/10/real-time-system-by-jane-w-s -
Real Time System by Jane W. S. Liu ha&ter ?.@ Solution /.?.@+ Whih of the follo%in! systems of &eriodi tasks are shedulable by the rate*monotoni al!orithm5 0y the earliest*deadline*first al!orithm5 &lain your ans%er. a.
T C (A, -), (4, -), (@, -)
a.
b.
Sol+
T C (A, -), (4, -), (@, -)
R,($) : +.D6+
" $*6 6*# $*8 " +.#+6 M R, schedulable utili%ation test is indeterminateFor R,! shortest period is highest priority w(t) " $! N " $ 7 6! ∴ T is schedulable w5(t) " $ ⌈t*6⌉⋅$ " t
N5 " A 7 #! ∴ T5 is schedulable w$(t) " $ ⌈t*6⌉⋅$ ⌈t*#⌉⋅$ " t N$ " 8 7 8! ∴ T$ is schedulable. 9ll tasks are schedulable under R,! there&ore the system is schedulable under R,. 7 ! ∴ the system is schedulable under EGF
.
T C (A, =), (6, =), (69, =)
Sol+ " C*6 C*5 C*5+ : .+$ M ∴ this system is not schedulable by any scheduling algorithm
d.
T C (A, =), (9, 6), (6, -)
Sol+ " C*6 5*+ $*5 " +.#8 M R,($) Schedulable utili%ation test is indeterminate! use time2demand analysis! w(t) " C! N " C 7 6 ∴ T is schedulable w5(t) " 5 ⌈ t*6 ⌉⋅C " t N5 " A 7 + ∴ T5 is schedulable ⌈
⌉⋅
⌈
⌉⋅
w$(t) " 5 t*6 C t*+ 5 " t N $ " 8 M 5 ∴T$ misses its deadline This system is not schedulable under R, 7 ∴ this system is schedulable under EGF
Earliest Deadline First (EDF Scheduling 7n /arliest 9eadline :irst 2/9:3 schedulin() at every schedulin( point the task havin( the shortest deadline is taken up !or schedulin(. This basic principles o! this al(orithm is very intuitive and simple to understand. The schedulability test !or /9: is also simple. task set is schedulable under /9:) i! and only i! it satis!ies the condition that the total processor utili+ation due to the task set is less than 1. /9: has been proven to be an optimal uniprocessor schedulin( al(orithm. This means that) i! a set o! tasks is not schedulable under /9:) then no other schedulin( al(orithm can !easibly schedule this task set. 7n the simple schedulability test !or /9:) #e assumed that the period o! each task is the same as its deadline. o#ever) in practical problems the period o! a task may at times be di!!erent !rom its deadline. 7n such cases) the schedulability test needs to be chan(ed.
more e!!icient implementation o! /9: #ould be as !ollo#s. /9: can be implemented by maintainin( all ready tasks in a sorted priority &ueue. sorted priority &ueue can e!!iciently be implemented by usin( a heap data structure. 7n the priority &ueue) the tasks are al#ays kept sorted accordin( to the pro'imity o! their deadline. When a task arrives) a record !or it can be inserted into the heap in K2lo(; n3 time #here n is the total number o! tasks in the priority &ueue. t every schedulin( point) the ne't task to be run can be !ound at the top o! the heap. When a task is taken up !or schedulin() it needs to be removed !rom the priority &ueue. This can be achieved in K213 time.
Solution liu_&".htm l
http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-w-s -
Real Time System by Jane W. S. Liu ha&ter ?.A Solution
/.?.A+ a) :se the time demand analysis method to sho% that the rate*monotoni al!orithm %ill &rodue a feasible shedule of the tasks (?,), (A,6) and (@,?).
Sol+ " *A 5*6 A*8 " +.6A
TG9 analysis2 w(A) " ! w5(A) " 5 ⌈A*A⌉⋅ " $ w$(A) " A ⌈A*A⌉⋅ ⌈A*6⌉⋅5 " #
N " 7 A! N5 " $ 7 A!
∴ T is schedulable ∴ T5 is schedulable
w$(5) " A ⌈5*A⌉⋅ ⌈5*6⌉⋅5 " 5
b) han!e the &eriod of one of the tasks in &art (a) to yield a set of tasks %ith the maimal total utili2ation %hih is feasible %hen sheduled usin! the rate*monotoni al!orithm. (onsider only inte!er #alues for &eriod)
Sol+ ?hange / such that2
w$(8) " A ⌈5*/⌉⋅ C " 8
"M
/ " $
) han!e the eeution time of one of the tasks in &art (a) to yield a set of tasks %ith the maimum total utili2ation %hih is feasible %hen sheduled usin! the rate*monotoni al!orithm. (onsider only re!ister #alues for the eeution time).
Sol+ ?hange the execution time o& tasks such that maximum possible utili%ation
w$(8) " e$ ⌈8*A⌉⋅ ⌈8*6⌉⋅5 " 8 "M
e$ $ C " 8
"M
e$ " 6
"M
T$ " (8!6)
Rate Monotonic Scheduling The term rate monotonic derives !rom a method o! assi(nin( priorities to a set o! processes as a monotonic !unction o! their rates. While rate monotoni c schedulin( systems use rate monotonic theory !or actually schedulin( sets o! tasks) rate monotonic analysis can be used on tasks scheduled by many di!!erent systems to reason about schedulablility. We say that a task is schedulable i! the sum o! its preemption) e'ecution) and blockin( is less than its deadline. system is schedulable i! all tasks meet their deadlines . Rate monotonic analysis provides a mathematical and scienti!ic model !or reasonin( about schedulability.
ssumptions Reasonin( #ith rate monotonic analysis re&uires the presence o! the !ollo#in( assumptions 0 Task s#itchin( is instantaneous. Tasks account !or all e'ecution time. Task interactions are not allo#ed. Tasks become ready to e'ecute precisely at the be(innin( o! their periods and relin&uish the C%E only #hen e'ecution is complete. Task deadlines are al#ays at the start o! the ne't period. Tasks #ith shorter periods are assi(ned hi(her priorities, the criticality o! tasks is not considered. Task e'ecution is al#ays consistent #ith its rate monot onic priority0 a lo#er priority task never e'ecutes #hen a hi(her priority task is ready to e'ecute.
Solution
s - liu_&""".html
http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-w-
Real Time System by Jane W. S. Liu ha&ter ?.? Solution Bi#e t%o different e&lanation of %hy the &eriodi tasks (6,), (=,) and (A,6) are /.?.?+ shedulable by the rate monotoni al!orithm.
Sol+ The priorities to tasks are assigned statically! be&ore the actual execution o& the task set. Rate ,onotonic scheduling scheme assigns higher priority to tasks with smaller periods. t is preempti'e (tasks are preempted by the higher priority tasks). t is an optimal scheduling algorithm among Pxed2priority algorithmsQ i& a task set cannot be scheduled with R,! it cannot be scheduled by any Pxed2priority algorithm.
The su&Pcient schedulability test is gi'en by
The term is said to be the processor utili%ation &actor (the &raction o& the processor time spent on executing task set). n is the number o& tasks. n our case *5 *C 5*6 " which is not less than +.D6 The abo'e condition is not necessaryQ we can do a somewhat more in'ol'ed su&Pcient and necessary condition test! as &ollows. Ne ha'e to guarantee that all the tasks can be scheduled! in any possible instance. n particular! i& a task can be scheduled in its critical instances! then the schedulability guarantee condition holds (a critical instance o& a task occurs whene'er the task is released simultaneously with all higher priority tasks). For that! we ha'e to use the method as mentioned in Exercise A.8.
Solution s - liu_2.htm l
http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-w-
Real Time System by Jane W. S. Liu ha&ter ?.D Solution
/.?.D+
This &roblem is onerned %ith the &erformane an beha#ior of rate*monotoni an earliest*deadline*first al!orithms. a. onstrut the initial se!ments in the time inter#al (9, D@9) of a rate*monotoni shedule and an earliest*deadline*first shedule of the &eriodi tasks (99, 69) (@9, @9), and (6@9, 99) %hose total utili2ation is 9.4-.
R,
=ote! the third task (the blue one) runs past its deadline &rom t " 58+ to t " 5A+. EGF
There are no missed deadlines in this schedule.
b. onstrut the initial se!ments in the time inter#al (9, D@9) of a rate* monotoni shedule and an earliest*deadline*first shedule of the &eriodi tasks (99, 69) (@9, @9), and (6@9, 69) %hose total utili2ation is .9. Sol R,
The third task (the blue one) runs past its deadline &rom 58+ to 56+ and &rom 85+ to 8A+. The third task will continue to be backlogged &arther and &arther each time a new -ob in the task is released! but the &irst and second task are not a&&ected. EGF
Task 5 e'entually misses its deadline. Once -obs start missing deadlines! almost e'ery -ob is going to miss its deadline.
Rate Monotonic !s" EDF Since the rst results published in 1HI> by Liu and Layland on the Rate onotonic 2R3 and /arliest 9eadline :irst 2/9:3 al(orithms) a lot o! pro(ress has been made in the schedulability analysis o! periodic task sets. En!ortunately) many misconceptions still e'ist about the properties o! these t#o schedulin( methods) #hich usually tend to !avor R more than /9:. Typical #ron( statements o!ten heard in technical con!erences and even in research papers claim that R is easier to analy+e than /9:) it introduces less runtime overhead) it is more predictable in overload conditions) and causes less "itter in task e'ecution. Since the above statements are either #ron() or not precise) it is time to clari!y these issues in a systematic !ashion) because the use o! /9: allo#s a better e'ploitation o! the available resources and si(nicantly improves system8s per!ormance. ost commercial RTKSes are based on R. R is simpler to implement on top o! commercial 2!i'ed priority3 kernels. /9: re&uires e'plicit kernel support !or deadline schedulin() but (ives other advanta(es.
Less overhead due to preemptions. ore uni!orm "itter control Metter aperiodic responsiveness. T#o di!!erent types o! overhead0 Overhead for job release /9: has more than R) because the absolute deadline must be updated at each "ob activation Overhead for context switch R has more than /9: because o! the hi(her number o! preemptions
esource access protocols! :or R *on %reemptive %rotocol 2*%%3 i(hest Locker %riority 2L%3 %riority 7nheritance 2%7%3 %riority Ceilin( 2%C%3 Ender /9: *on %reemptive %rotocol 2*%%3 9ynamic %riority 7nheritance 29-%7%3 9ynamic %riority Ceilin( 29-%C%3 Stack Resource %olicy 2SR%3
Solution
s - liu_'1".htm l
http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-w-
Real Time System by Jane W. S. Liu ha&ter ?.4 Solution
/.?.4+ al!orithm. a) Sol+
The Periodi Tasks (-,), (=,6), (?,) are sheduled aordin! to the rate*monotoni
;ra% Time ;emand >untion of the tasks
b)
3re the tasks shedulable5 Why or %hy not 5
Sol+ =o. ased on the Time Gemand Function graph! Task $ did not touch or go below the dash line by its deadline at time A. n another word! it can not meet its deadline and there&ore not schedulable.
)
an this !ra&h be used to determine %hether the tasks are shedulable aordin! to an arbitrary &riority*dri#en al!orithm5
Sol+ =o. This graph is &undamentally based on &ixed priority dri'en algorithm which assigns the same priority to all -obs in each task. n the graph! T5 is built on top o& T since all -obs in T ha'e a higher priority than all -obs in T5. T$ is built on top o& T and T5since all -obs in T and T5 ha'e a higher priority than all -obs in T$. This graph does not depict dynamic priority dri'en algorithm! such as earliest deadline &irst (EGF). n EGF! any -ob in a task can ha'e a higher priority at a speci&ic moment depending on its deadline compared to the -obs o& other tasks.
There&ore! this graph cannot be used t o determine the schedulability o& an arbitrary priority2 dri'en algorithm.
Time#demand Analysis Simulate system behaviour at the critical instants. :or each "ob Ji)c released at a critical instant) i! Ji)c and all hi(her priority tasks complete e'ecutin( be!ore their relative deadlines the system can be scheduled. Compute the total demand !or processor time by a "ob released at a critical instant o! a task) and by all the hi(her-priority tasks) as a !unction o! time !rom the critical instant, check i! this demand can be met be!ore the deadline o! the "ob0 Consider one task) Ti) at a time) startin( hi(hest priority and #orkin( do#n to lo#est priority. :ocus on a "ob) Ji) in Ti) #here the release time) t) o! that "ob is a critical instant o! T Compare time-demand !unction) #i2t3) and available time) t0 7! #i2t3 @ t at some t @ 9i) the "ob) Ji) meets its deadline) t N 9i 7! #i2t3 F t !or all O t @ 9i then the task probably cannot complete by its deadline, and the system likely cannot be scheduled usin( a !i'ed priority al(orithm *ote that this is a su!!icient condition) but not a necessary condition. Simulation may sho# that the critical instant never occurs in practice) so the system could be !easible Ese this method to check that all tasks are can be scheduled i! released at their critical instants, i! so conclude the entire system can be scheduled. The time-demand) #i2t3) is a staircase !unction #ith steps at multiples o! hi(her priority task periods %lot the time-demand versus available time (raphically) to (et intuition into approach
Solution
http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-w-s-
liu_"'1!.html
Real Time System by Jane W. S. Liu ha&ter ?.9 Solution
/.?.9+
Whih of the follo%in! fied*&riority task is not shedulable5 &lain your ans%er.
T(@,)
T6(-,)
T-(D,6.@)
T=(?,)
Sol+
& Ni(t) 4" t! the task is schedulable.
9ssume R,*G, scheduling algorithm is used. /riority T5MTMT$MTC ndex! i! is assigned to each task according to its priority.
T5 i " ! T i " 5! T$ i " $.! TC i " C
?heck t " $! 8! A! D! #! +! 5! C! 8! A
N(t) " 4 t!
t" $! 8! A! D! #! +! 5! C! 8! A
"M Schedulable
N5(t) " ⌈t*$⌉
N5($) " " 5 4"$
N$(t) " 5.8 ⌈t*$⌉ ⌈t*8⌉
"M Schedulable
(check 5.8"C.8 "M min t "8)
N$(8) " 5.85 " 8.8 N$(A) " 5.855 " A.8 N$(D) " 5.8$5 " D.8 "M ,iss deadline! D =ot Schedulable
NC(t) " ⌈t*$⌉ ⌈t*8⌉ 5.8⌈t*D⌉
(check 5.8"8.8 "M min t "A)
NC(A) " 555.8 " D.8 NC(D) " $55.8 " 6.8 NC(#) " $58 "
NC(+) " C58 " 5 NC(5) " C$8 " $ NC(C) " 8$8 " C 4" C
"M Schedulable
T$ is not a schedulable task
Time $ound in Fi%ed#&riority Scheduling
Since #orst-case response times must be determined repeatedly durin( the interactive desi(n o! realtime applicatio n systems) repeated e'act computation o! such response times #ould slo# do#n the desi(n process considerably. 7n this research) #e identi!y three desirable properties o! estimates o! the e'act response times0 continuity #ith respect to system parameters, e!cient computability, and appro'imability. We derive a techni&ue possessin( these properties !or estimatin( the #orst case response time o! sporadic task systems that are scheduled usin( 'ed priorities upon a preemptive uniprocessor . When a (roup o! tasks share a common resource 2such as a processor) a communication medium3) a schedulin( policy is necessary to arbitrate access to the shared resource. Kne o! the most intuitive policies consists o! assi(nin( :i'ed %riorities 2:%3 to the tasks) so that at each instant in time the resource is (ranted to the hi(hest priority task re&uirin( it at that instant. 9ependin( on the assi(ned priority) a task can have lon(er or shorter response time) #hich is the time elapsed !rom re&uest o! the resource to the completion o! the task. Since #orst case response times must be determined repeatedly durin( the interactive desi(n o! realtime applicatio n systems) repeated e'act computation o! such response times #ould slo# do#n the desi(n process considerably. 7n this research) #e identi!y three desirable properties o! estimates o! the e'act response times0 continuity #ith respect to system parameters) e!!icient computability) and appro'imability. We derive a techni&ue possessin( these properties !or estimatin( the #orst-case response time o! sporadic task systems that are scheduled usin( !i'ed priorities upon a preemptive uniprocessor.
Solution liu_3.htm l
http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-w-s-
Real Time System by Jane W. S. Liu ha&ter ?. Solution
/.?.+ >ind the maimum &ossible res&onse time of tasks T= in the follo%in! fied*&riority system by sol#in! the e$uation %=(t) C t, iterati#ely T C (@,), T6 C (-,),
T- C (A,.?), and T= C (A,-.@)
Sol+ teration
wC(t")() " $.8 ⌈ *8 ⌉⋅ ⌈ *$ ⌉⋅ ⌈ *6 ⌉⋅.A " $.8 .A " D. teration 5 wC(t"D)(5) " $.8 ⌈ D*8 ⌉⋅ ⌈ D*$ ⌉⋅ ⌈ D*6 ⌉⋅.A " $.8 5 $ .A " +. teration $ wC(t"+)($) " $.8 ⌈ +*8 ⌉⋅ ⌈ +*$ ⌉⋅ ⌈ +*6 ⌉⋅.A " $.8 5 C $.5 " 5.D teration C wC(t"5.D)(C) " $.8 ⌈ 5.D*8 ⌉⋅ ⌈ 5.D*$ ⌉⋅ ⌈ 5.D*6 ⌉⋅.A " $.8 $ 8 $.5 " C.D teration 8 wC(t"C.D)(8) " $.8 ⌈ C.D*8 ⌉⋅ ⌈ C.D*$ ⌉⋅ ⌈ C.D*6 ⌉⋅.A " $.8 $ 8 $.5 " C.D ,ax possible response time " C.D
Time $ound in Fi%ed#&riority Scheduling Since #orst-case response times must be determined repeatedly durin( the interactive desi(n o! realtime application systems) repeated e'act computation o! such response times #ould slo# do#n the
desi(n process considerably. 7n this research) #e identi!y three desirable properties o! estimates o! the e'act response times0 continuity #ith respect to system parameters, e!cient computability, and appro'imability. We derive a techni&ue possessin( these properties !or estimatin( the #orst case response time o! sporadic task systems that are scheduled usin( 'ed priorities upon a preemptive uniprocessor . When a (roup o! tasks share a common resource 2such as a processor) a communication medium3) a schedulin( policy is necessary to arbitrate access to the shared resource. Kne o! the most intuitive policies consists o! assi(nin( :i'ed %riorities 2:%3 to the tasks) so that at each instant in time the resource is (ranted to the hi(hest priority task re&uirin( it at that instant. 9ependin( on the assi(ned priority) a task can have lon(er or shorter response time) #hich is the time elapsed !rom re&uest o! the resource to the completion o! the task. Since #orst case response times must be determined repeatedly durin( the interactive desi(n o! realtime application systems) repeated e'act computation o! such response times #ould slo# do#n the desi(n process considerably. 7n this research) #e identi!y three desirable properties o! estimates o! the e'act response times0 continuity #ith respect to system parameters) e!!icient computability) and appro'imability. We derive a techni&ue possessin( these properties !or estimatin( the #orst-case response time o! sporadic task systems that are scheduled usin( !i'ed priorities upon a preemptive uniprocessor.
Solution liu_&2&3.htm l
http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-w-s-
Real Time System by Jane W. S. Liu ha&ter ?.- Solution
/.?.-+ tasks+
>ind the len!th of an in*&hase le#el*- busy inter#al of the follo%in! fied*&riority
T C (@, ), T6 C (-,), T- C (A, .?), and T= C (A, -.@) Sol+ The le'el2$ busy inter'al is based on T ! T5! and T$ t " ⌈ t*8 ⌉⋅ ⌈ t*$ ⌉⋅ ⌈ t*6 ⌉⋅.A
t " C.A " length o& in2phase le'el2$ busy inter'al
$usy 'nter!als 9e!inition0 level-Pi busy interval 2t) tB be(ins at an instant t #hen 213 all "obs in Ti released be!ore this instant have completed) and 2;3 a "ob in Ti is released.
The interval ends at the !irst instant t a!ter t #hen all "obs in Ti released since t are complete. :or any t that #ould &uali!y as the end o! a level-Pi busy interval) a correspondin( t e'ists. 9urin( a level-Pi busy interval) the processor only e'ecutes tasks in Ti other tasks can be i(nored.
9e!inition0 We say that a level-Pi busy interval is in phase i! the !irst "ob o! all tasks that e'ecute in the interval are released at the same time. :or systems in #hich each task8s relative deadline is at most its period) #e ar(ued that an upper bound on a task8s response time could be computed by considerin( a Qcritical instant scenario in #hich that task releases a "ob to(ether #ith all hi(her-priority tasks. 7n other #ords) #e "ust consider the !irst "ob o! each task in an in-phase system. :or many years) people "ust assumed this approach #ould #ork i! a task8s relative deadline could e'ceed its period. Lehoc+ky sho#ed that this Q!olk #isdom that only each task8s !irst "ob must be considered is !alse by means o! a countere'ample. The (eneral schedulability test hin(es upon the assumption that the "ob #ith the ma'imum response occurs #ithin an in-phase busy interval.
Solution
http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-w-s-
liu_".html
Real Time System by Jane W. S. Liu ha&ter ?.@ Solution
/.?.@+ a.
3 system onsists of three &eriodi tasks+ (-, ), (@, 6), and (A, -).
What is the total utili2ation5
a. b.
Sol+ " *$ 5*8 $*6 : .
onstrut an earliest*deadline*first shedule of this system in the inter#al (9, -6). Label any missed deadlines. c.
Sol+
3ellow stripes indicates missed deadlines.
Su&&ose %e %ant to redue the eeution time of the task %ith &eriod - in order to make mthe task system shedulable aordin! to the earliest*deadline*first al!oorithm. What is the minimum amount of redution meessary for the system to be shedulable by the earliest*deadline*first al!orithm5 d.
Sol+
3ellow stripes indicates missed deadlines.
Su&&ose %e %ant to redue the eeution time of the task %ith &eriod - in order to make the task system shedulable aordin! to the earliest*deadline*first al!oirthm. What is the minimum amount of redution neessary for the system to be shedulable by the earliest*deadline*first al!orithm5 e.
Sol+
" (2x)*$ 5*8 $*6 7 x I +.$58
"tili#ation $ounds for %D& Scheduling The utili+ation bound !or /arliest 9eadline :irst schedulin( is e'tended !rom uniprocessors to homo(eneous multiprocessor systems #ith partitionin( strate(ies . :irst results are provided !or a basic task model) #hich includes periodic and independent tasks #ith deadlines e&ual to periods. n bounds depend on the allocation al(orithm) di fferent allocation al(orithms have been considered) ran(in( !rom simple heuristics to optimal allocation al(orithms. s multiprocessor utili+ation bounds !or /9: schedulin( depend stron(ly on task si+es) all these bounds have been obtained as a !unction o! a parameter #hich takes task si+es into account.Theoretically) the utili+ation bounds !or multiprocessor /9: schedulin( can be considered a partial solution to the bin-packin( problem) #hich is kno#n to be *%complete. The basic task model is e'tended to include resource sharin( release "itter) deadlines less than periods) aperiodic tasks) non-preemptive sections) conte't s#itches and mode chan(es.
Solution
http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-w-s-
liu_"2&.html
Real Time System by Jane W. S. Liu ha&ter ?.6 Solution
/.?.6+
a) :se the time*demand analysis method to sho% that the set of &eriodi tasks (@,
), (A, 6), (=, =) is shedulable aordin! to the rate*monotoni al!orithm.
Shortest period has the highest priority... T (8! ) w(t) " N " 7 8 ∴ T is schedulable T5 (6! 5) w5(t) " 5 ⌈t*8⌉⋅ N5 " $ 7 6 ∴ T5 is schedulable T$ (C! C) w$(t) " C ⌈t*8⌉⋅ ⌈t*6⌉⋅5 N$ " 6 7 C ∴ T$ is schedulable
b) Su&&ose that %e %ant to make the first units of eah re$uest in the task (A,6) non&reem&table. What is the maimum #alue of so that the system remains shedulable aordin! to the rate* monotoni al!orithm5 Solution +
T"J(8!)(6!5)(C!C)K T"(8!)
T5"(6!5)
T$"(C!C) (in order o& priority! T being highest)
T5 (6! 5) can be made nonpreemptable &or the &irst 5 time units (its entire duration) and still allow the system to be scheduled on time.
Solution 6+
& we make the &irst x units o& Task (6! 5) nonpreemptable T$ is una&&ected by this change since T5 is a higher priority task anyway. T5 is also una&&ected. ts response time will not be a&&ected by the change (i& anything it would impro'e) N" x 4"8! x4"C
x can be at most C time units. ut since Task 5 (6! 5)! only has an execution time o& 5 time units! x can be 5 time units
Solution
http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-w-s-
liu_120.html
Real Time System by Jane W. S. Liu ha&ter ?.6- Solution
/.?.6-+
3 system ontains tasks T C (9,-), T6C (?,=), T- C (=9,9) and T= C (@9,@). The
total blokin! due to all fators of the tasks are b C @, b6 C , b- C = and b= C 9, res&eti#ely. These tasks are sheduled on the ;> basis. Whih tasks (or task) are (or is) shedulable5 &lain your ans%er.
Sol+ For ith task to be scheduled by EGF basis
" $*+ C*A +*C+ 8*8+ " +.$ +.58 +.58 +. " +.# &or T +.# b*+ " +.# 8*+ " .C M
...not schedulable
&or T5 +.# *A " +.# +.+A58 " +.#A58 4 ...schedulable &or T$ +.# C*C+ " +.# +.+ " 4"
...schedulable
+.# +*8+ " +.# +.5 " . M
...not schedulable
&or TC
/arliest deadline !irst schedulin( %arliest deadline first 2%D&3 or least ti'e to go is a dynamic schedulin( al(orithm used in realtime operatin( systems to place processes in a priority
&ueue. Whenever a schedulin( event occurs
2task !inishes) ne# task released) etc.3 the &ueue #ill be searched !or the process closest to its deadline. This process is the ne't to be scheduled !or e'ecution. #hen the system is overloaded) the set o! processes that #ill miss deadlines is lar(ely unpredictable 2it #ill be a !unction o! the e'act deadlines and time at #hich the overload occurs.3 This is a considerable disadvanta(e to a real time systems desi(ner. The al(orithm is also di!!icult to implement in hard#are and there is a tricky issue o! representin( deadlines in di!!erent ran(es 2deadlines must be rounded to !inite amounts) typically a !e# bytes at most3. 7! a modular arithmetic is used to calculate !uture deadlines relative to no#) the !ield storin( a !uture relative deadline must accommodate at least the value o! the 22duration o! the lon(est e'pected time to completionU V ;3 N no#3. There!ore %D& is not commonly !ound in industrial real-time computer systems. 7nstead) most real-time computer systems use !i'ed priority schedulin( 2usually rate-monotonic schedulin(3. With !i'ed priorities) it is easy to predict that overload conditions #ill cause the lo#priority processes to miss deadlines) #hile the hi(hest-priority process #ill still meet its deadline. /9: is an optimal schedulin( al(orithm on preemptive uniprocessors) in the !ollo#in( sense0 i! a collection o! independent jobs, each characteri+ed by an arrival time) an e'ecution re&uirement and a deadline) can be scheduled 2by any al(orithm3 in a #ay that ensures all the "obs complete by their deadline) the %D& #ill schedule this collection o! "obs so they all complete by their deadline.
Solutio n s - liu_#.htm l
http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-w-
Real Time System by Jane W. S. Liu ha&ter ?.- Solution
/.?.-+
"nterru&ts ty&ially arri#e s&oradially. When an interru&t arri#es, interru&t handlin!
is ser#ied (i.e., eeuted on the &roessor) immediately and in a non&reem&table fashion. The effet of interru&t handlin! on the shedulability of &eriodi tasks an be aounted for in the same manner as blokin! time. To illustrate this, onsider a system of four tasks+ T C (6.@, 9.@), T 6 C (=, ), T - C (9, ), and T = C (-9, ?). Su&&ose that there are t%o streams of interru&ts. The interrelease time of interru&ts in one stream is ne#er less than 4, and that of the other stream is ne#er less than 6@. Su&&ose that it takes at most 9.6 units of time to ser#ie eah interru&t. Like the &eriodi tasks interru &t handlin! tasks (i.e., the stream of interru&t handlin! 1obs) are !i#en fied &rioriteies. They ha#e hi!her &riorities than the &eriodi tasks, and the one %ith a hi!her rate (i.e., shorter minimum interrelease time) has a hi!her &riority. a. What is the maimum amount of time eah 1ob in eah &eriodi task may be delayed from om&letion by interru&ts5
Sol+ & an interrupt comes while a -ob is running or a higher priority -ob is running! the -ob
b " ⌈e*pint!⌉⋅eint! ⌈e*pint!5⌉⋅eint!5 " ⌈+.8*#⌉⋅+.5 ⌈+.8*58⌉⋅+.5 " +.C w5(t) " +.8⋅⌈t*5.8⌉ +.5⋅⌈t*#⌉ +.5 ⋅⌈t*58⌉ " t N5 " .#
The amount o& time taken by interrupt handlers between the release o& the &irst -ob in T5 and it
w$(t) " +.8⋅⌈t*5.8⌉ ⋅⌈t*C⌉ +.5⋅⌈t*#⌉ +.5 ⋅⌈t*58⌉ " t N$ " $.C
b$ " +.5 ⋅⌈$.C*#⌉ +.5 ⋅⌈$.C*58⌉ " +.C
wC(t) " A +.8 ⋅⌈t*5.8⌉ ⋅⌈t*C⌉ ⋅⌈t*+⌉ +.5⋅⌈t*#⌉ +.5 ⋅⌈t*58⌉ " t NC " D.
bC " +.5 ⋅⌈D.*#⌉ +.5 ⋅⌈D.*58⌉ " +.A
Let the maimum delay suffered by eah 1ob in T i in &art (a) be b i, for i C , 6, -, and =. om&ute the time*demand funtions of the tasks and use the time*demand analysis method to determine %hether e#ery &eriodi task T i an meet all its deadlines if ; i is e$ual to &i. b.
Sol+ (This is a bit redundant gi'en part (a) abo'e.)
w(t) " b e " +.C +.8 " +.# " t
N " +.# 7 5.8 ∴T is schedulable
w5(t) " +.C +.8⋅⌈t*5.8⌉ " t
N5 " .# 7 C
∴T5 is schedulable
w$(t) " +.C +.8⋅⌈t*5.8⌉ ⋅⌈t*C⌉ " t N$ " $.C 7 + ∴T$ is schedulable
wC(t) " +.A A +.8⋅⌈t*5.8⌉ ⋅⌈t*C⌉ ⋅⌈t*+⌉ " t
NC " D. 7 $+ ∴TC is schedulable
"n one or t%o sentenes, e&lain %hy the ans%er you obtained in (b) about the shedulability of the &eriodi tasks is orret and the method you use %orks not only for this system but also for all inde&endent &reem&ti#e &eriodi tasks. c.
Sol+ The interrupt beha'ior described in the problem is the same as the beha'ior o& a high priority periodic task. There&ore! the amount o& time taken handling interrupts can be analy%ed with the same method as high priority tasks.
Solution
http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-w-s-
liu_3&".html
Real Time System by Jane W. S. Liu ha&ter D. Solution
/.D.+ 3 system ontains three &eriodi tasks. They are (6.@,), (=,9.@), (@,9.D@), and their total utili2ation is 9.=D@.
a) The system also ontains a &eriodi ser#er (6,9.@). The ser#er is sheduled %ith the &eriodi tasks rate*monotonially. ) Su&&ose that the &eriodi ser#er is a basi s&oradi ser#er. What are the res&onse time of the follo%in! t%o a&eriodi 1obs+ Kne arri#es at - and has eeution time 9.D@, and one arri#es at D.@ and has eeution time 9.?. Sol+
N9 " C.58 2 $ " .58 N95 " #.A 2 D.8 " 5.
6) Su&&ose that the &eriodi ser#er is a deferrable ser#er. What are the res&onse times of the abo#e t%o a&eriodi 1obs. Sol+
N9 " C.58 2 $ " .58 N95 " 6. 2 D.8 " +.A
b) 7ote that the utili2ation of the &eriodi ser#er in &art (a) is 9.6@. We an !i#e the ser#er different &eriods %hile kee&in! its utili2ation fied at 9.6@. Re&eat () and (6) in &art (a) if the &eriod of the &eriodi ser#er is . Sol+ ?ase
N9 " 8.58 2 $ " 5.58 N95 " #.A 2 D.8 " 5. ?ase 5
N9 " 8.58 2 $ " 5.58 N95 " #. 2 D.8 " .A
) an %e im&ro#e the res&onse times by inreasin! the &eriod of the &eriodi ser#er 5 Sol+ @engthening the period can impro'e response time because a layer period allows us to increase the execution time so that more o& the sporadic -ob can run but period must remain short enough to replenish the budget be&ore the next aperiodic -ob arri'es and short enough to remain the highest priority task.
d) Su&&ose that as a desi!ner you %ere !i#en () the harateristis of the &eriodi tasks, that is, (&,e), (&6,e6),.....(&n,en), (6) the minimum inter#al &a bet%een arri#als of a&eriodi 1obs, and (-) the maimum eeution time re$uired to om&lete any a&eriodi 1ob. Su&&ose that you are asked to hoose the eeu tion bud!et and &eriod of a deferrable ser#er. Su!!est a set of !ood desi!n rules. Sol+ . /eriodic Starts 5. ,aximum / a $. ,inimum e a
& /s " /a and es " ea! then all aperiodic -obs will &inish as soon as possible. & the system is unschedulable! make the period as long as possible (and the budget)! so that as many -obs can &inish as soon as possible.
Solution
http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-w-s-
liu_&.html
Real Time System by Jane W. S. Liu ha&ter D.6 Solution
/.D.6+
3 system ontains three &eriodi tasks. They are (-,), (=,9.@), (@,9.@).
The task system also ontains a s&oradi ser#er %hose &eriod is 6. The s&oradi ser#er is sheduled %ith the &eriodi tasks rate*monotonially. >ind the maimum utili2ation of the ser#er if all deadlines of &eriodi tasks are surely met. ) Su&&ose that the ser#er in &art (a) is a &ure &ollin! ser#er. What are the res&onse time of the follo%in! t%o a&eriodi 1obs+ one arri#es at 6.- and has eeution time 9.A , and one arri#es at 6.D and has eeution time 9.? 5
Sol+ Find max es so system is schedulable. W1(t) = 1 + ⌈t/2⌉.es = t
"M W2(t) = 1 + ⌈3/2⌉.es = 3 => es = W2(t) = 0.5 + ⌈t/2⌉.es + ⌈t/3⌉ = t => es = 7/4 W3(t) = 1 + ⌈t/2⌉.es
+
⌈t /3⌉ + ⌈t/4⌉.0.5 = t
"M es " +.8 Hence! e
s
"4 +.8!
" es*/s " +.8*5 " *C so!
N9 " A.$ 2 5.$ " C N95 " A. 2 5.D " $.C 6) Su&&ose that the ser#er in &art (a) is a basi s&oradi ser#er. What are the res&onse time of the abo#e t%o a&eriodi 1obs5 Sol+
N9 " $.$ 2 5.$ " N95 " C.6 2 5.D " 5.
:About the Sporadic Server: • DS may delay lower-priority tasks. • Sporadic
Servers
(SS)
rules
ensure
that
each
sporadic
server
(ps, es)
never
demands more processor time than the periodic task (ps, es). Sporadic Server in i!ed-"riority Systems: #otations • $: system o% n independent, preemptable periodic tasks. • $&: subset o% periodic tasks with hi'her priorities than the server priority. • $ $& are either busy or idle. • Server busy interval: an aperiodic *ob arrives at an empty +ueue, the +ueue becomes empty a'ain. • tr: the latest (actual) replenishment time. • t%: the %irst instant a%ter tr at witch server be'ins to e!ecute. • te: the latest e%%ective replenishment time. • At any time t: /01#: be'innin' instant o% the earliest busy interval amon' the latest conti'uous e+uence o% busy intervals o% $& that started be%ore t. /#D: end o% the latest busy interval i% this interval ends be%ore t, in%inity i% the interval ends a%ter t. Simple Sporadic Server • 2onsumption 3ules: At any t 4 tr, bud'et is consumed at the rate o% 5 per unit time until bud'et is e!hausted when 25: the server is e!ecutin' 63 27: the server has e!ecuted since tr and /#D 8 t. • 3eplenishment 3ules: 35:
1nitially
when
system
be'ins
e!ecution
and
each
time
when bud'et is
replenished, bud'et 9 es and tr 9 current time. 37: At time t%, i% /#D 9 t% then te 9 ma!(tr, /01#), i% /#D 8 t% then te 9 t%. #e!t replenishment time is te ps. 3;: a) 1% te ps is earlier than t%, bud'et is replenished as soon as it is e!hausted.
b) 1% $ becomes idle be%ore te ps and becomes busy a'ain at tb, bud'et is replenished at min(te ps, tb).
Solution liu_2"3.html
http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-w-s-
Real Time System by Jane W. S. Liu ha&ter D.- Solution
/.D.-+
onsider a system ontainin! the follo%in! &eriodi tasks+ T C (9,6), T6 C (=,-) andTC (6,=). 3 &eriodi ser#er of &eriod A is used to shedule a&eriodi 1obs.
a) Su&&ose that the ser#er and the tasks are sheduled rate*monotonially. ) "f the &eriodi ser#er is a deferrable ser#er, ho% lar!e an its maimum eeution bud!et be 5 Sol+ For su&&icient condition (because /s is highest priority ser'er)
4" R, 4" (n2)0(u 5)*(u) 2 1 *$
5*+ $*C C*5 s 4" $0(u 5)*(u) 2 1 s 4" +.+8# es " s./s " +.66D#
6) "f the &eriodi ser#er is a s&oradi ser#er, ho% lar!e an its maimum eeution bud!et be 5 Sol+ & we try to &ind es using TG9. Suppose &inal -ob completes exactly at deadline.
5 " w$(5) " C es es⋅⌈(5 2 es)*6⌉ ⋅⌈5*+⌉ $⋅⌈5*C⌉ 8 " es es⋅⌈(5 2 es)*6⌉ by sol'ing! es " .58 So! we can take maximum execution budget as .58.
b) Su&&ose that the ser#er and the tasks are sheduled on the ;> basis. Re&eat the (a). Sol+ tasks are schedulable i&!
4" R, 4" (n2)0(u 5)*(u) 2 1 5*+ $*C C*5 es⋅⌈(6 2 es)*5 ⌉ 4" by sol'ing! es " 5.8+A So! we can take maximum execution budget as 5.8+A.
Solution liu_'.html
http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-w-s-
Real Time System by Jane W. S. Liu ha&ter D.= Solution
/.D.=+
onsider a system that ontains t%o &eriodi tasks T C (D,6) and T6 C (9,-). There is a
band%idth &reser#in! ser#er %hose &eriod is ?. su&&ose that the &eriodi tasks and the ser#er are sheduled rate*monotonially. a) Su&&ose that the ser#er is deferrable ser#er. ) What is the maimum ser#er si2e 5 Sol+ ,ax si%e N(t) " 5 es ⌈(t 2 es)*A⌉.es " t 5 es ⌈(t 2 es)*A⌉.es 4 D es ⌈(t 2 es)*A⌉.es 4 8 simpli&ies to2 2 5( 2 ) 4 8 $ 2 $ 4 8 es es 4 8 es " 5.8
N5(t) " $ es ⌈(t 2 es)*A⌉.es ⌈t*5⌉.es " t ⌈
⌉
⌈
⌉
$ es (+ 2 es)*A .es +*5 .es 4 + put! es " C 2 ! es 4 C!
$ C 2 5(C 2 ) C 4 + 8 2 $ C 4 + $ 4 # "$ es 4"
es M C!
$ C 5(C ) C 4 + $ 5 4 + 5 " 2$ " 2.8 put e s" C es 4" C 2 .8 " 5.8 Hence! es " "M " e s*/s " *A
6) onsider t%o a&eriodi 1obs 3 and 36. The eeution times of the 1obs are e$ual to .9 and 6.9, res&eti#ely. Their arri#al times are 6 and @. What are their res&onse time 5 Sol+
N9 " $ 2 5 " N95 " $ 2 8 " 6 b) Su&&ose that the ser#er is a sim&le s&oradi or S&SL s&oradi ser#er. ) What is the maimum ser#er si2e 5 Sol+ N(t) " 5 ⌈t*A⌉.es " t 5 ⌈D*A⌉.es 4 D es 4" 5.8
N5(t) " $ ⌈t*A⌉.es ⌈t*D⌉.5 " t $ ⌈+*A⌉.es ⌈+*D⌉.5 4 + es 4" .8 " es*/s " .8*A 6) >ind the res&onse times of 1obs 3 and 36 in &art (a) if the ser#er is a S&SL ser#er. Sol+
N9 " $ 2 5 " N95 " $.8 2 8 " 6.8
Solution
http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-w-s-
liu_!.html
Real Time System by Jane W. S. Liu ha&ter D.@ Solution
/.D.@+
Su&&ose that the &eriodi tasks in the &re#ious &roblem are sheduled alon! %ith aser#er on the earliest deadline first basis.
a) What is the maimum ser#er si2e if the ser#er si2e if the ser#er is a deferrable ser#er5 "s this si2e a funtion of the &eriod of the ser#er5 "f not, %hy not5 "f yes, %hat is the best hoie of ser#er si2e5
b) What is maimum ser#er si2e if the ser#er is a total band%idth ser#er5
Sol+
Someone pointed out that problem C has a period o& A! and problem D.8 says to repeat the setup in the pre'ious problem. sing ps " A greatly simpli&ies the problem and probably was what was intended by the author. n part (c) when repeating part (b) with the total bandwidth ser'er. The second aperiodic -ob that arri'es at time t"8 has execution time o& 5! so the ser'er
5*D $*+ es*/s ( (/s 2 es)*Gi) 4"
5*D $*+ es*/s ( (/s 2 es)*D) 4"
and 5*D $*+ es*/s ( (/s 2 es)*+) 4"
by sol'ing abo'e two euations! we can conclude. s depends on the /s. For maximum si%e ser'er! /s 2M +. "M s " +.C (max).
Howe'er! we want /s to be long enough to keep context switch time low. n this case! choose /s close to interrelease time o& the aperiodic -obs and es close to the execution time o& the aperiodic -obs. n this case choose /s " $.5! which gi'es s " +.$ and es ".+.
) >ind the res&onse time of 3 and 36 in &roblem D.= for ser#ers in &art (a) and (b). Sol+
)
N9 " $ 2 5 " N95 " D 2 8 " 5 5)
at t " 5! d " 5 *(5#*D+) " 5 D+*5# " C.C at t " 8! d5 " 8 *(5#*D+) " 8 D+*5# " D.C
N9 " $ 2 5 " N95 " D 2 8 " 5
Solution
http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-ws - liu_#"!1.htm l
Real Time System by Jane W. S. Liu ha&ter D.4 Solution
/.D.4+
;a#is et al., su!!ested a dual &riority sheme for shedulin! a&eriodi 1obs in the
midst of &eriodi tasks. 3ordin! to dual &riority sheme, the system kee&s three bands of &riority, eah ontainin! one or more &riority le#els. The hi!hest band ontains real time &riorities+ they are for hard real time tasks. Real time &riorities are assi!ned to hard real time tasks aordin! to some fied &riority sheme. The middle &riority band is for a&eriodi 1obs. The lo%est &riority band is also hard real time tasks. S&eifially, %hen 1obs J i,k in a &eriodi task Ti C (&i, ei, ;i) is released , it has a &riority in the lo%est &rior ity band until its &rior ity &romotion time. 3t its &rior ity &romotion time, its &riority is raised to its real time &riority. Let Wi denote the maimum res&onse time of all 1obs in Ti %hen they eeute at the real time &riority of the task. The &riority &romotion time of eah 1ob is Ni C ;i * Wi from its release time. Sine Wi an be om&uted off line or at admission ontr ol time, the releas e &romotion time Ni for 1obs in eah tasks Ti needs to be om&uted only one. 0y delayin! as muh as &ossible the shedulin! of e#ery hard real time 1obs at its real time &riority, the sheduler automatially reates slaks for a&eriodi 1obs. a) Bi#e an intuiti#e ar!ument to su&&ort the laim that this sheme %ill not ause any &eriodi 1ob to miss its deadline if the system of &eriodi tasks is shedulable. Sol+ n the worst case! any periodic -ob in in Ti will take at most Ni time to execute lea'ing 3i " Gi 2 Ni o& slack. & the -ob does not &inish in the &irst 3i time units! it still has Ni le&t be&ore its deadline. The -ob will still &inish be&ore its deadline because Ni is the longest time it can possibly take.
b) 3 system ontains three &eriodi task+ They are (6.@,9.@), (-,) and (@,9. @). om&ute the &riority &romotion times for 1obs in eah of the tasks if the tasks are sheduled rate*monotonially.
Sol+ Norst case Ni when all -obs released at same time.
N " +.8 w5(t) " 0t*5.81.+.8 " t +.8 " .8 " t
3 " G 2 N " 5.8 2 +.8 " 5
N5 " .8
35 " G5 2 N5 " $ 2 .8 " .8
w$(t) " +.8 0t*5.81.+.8 0t*$1 " t +.8 +.8 " 5 " t N$ " 5 3$ " G$ 2 N$ " 8 2 5 " $
) Su&&ose that there are t%o a&eriodi 1obs. Kne arri#es at .4, and the other arri#es at =.A. Their eeution times are 6. om&ute the res&onse times of these 1obs in a dual &riority system in %hih there is only one &riority le#el in the middle &riority band one &riority le#el in the lo%est &riority band. o% muh im&ro#ement is !ained o#er sim&ly shedulin! the a&eriodi 1obs in the bak!round of rate monotonially sheduled &eriodi tasks5
Sol+
N9 " D.8 2 .# " 8.A N95 " 5 2 C.6 " D.5
N9 " C 2 .# " 5. N95 " D 2 C.6 " 5.5
d) an the dual &riority shem e be modified and used in a system %here &erio di task s are sheduled aordin! to the ;> al!orithm5 "f no, briefly e&lain %hy8 if yes, briefly desribe the neessary modifiation.
Sol+ To make the dual priority scheme with EGF! we need to complete Ni! which is mere di&&icult because tasks priorities can change. One approach would be to calculate Ni by adding the time demanded by tasks with shorter relati'e deadline (which can be computed o&&line) to the execution time Ti and the amount o& time needed to complete -obs with relati'e deadlines longer than Gi that ha'e been released and ha'e absolute deadlines be&ore the most recently released -ob in Ti.
Solut ion s - liu.htm l
http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-w-
Real Time System by Jane W. S. Liu ha&ter D.6- Solution
/.D.6-+
Su&&ose that the inter#als bet%een arri#als of s&oradi 1obs are kno%n to be in the
ran!e (a,b). The eeution time of eah s&oradi 1ob is at most e (EC a) units. Su&&ose relati#e deadlines of s&oradi 1obs are e$ual to a. Nou are asked to desi!n a band%idth &reser#in! ser#er that %ill be sheduled rate monotonially %ith other &eriodi tasks. S&oradi 1obs %aitin! to be om&leted are eeuted on the first in first out basis in the time inter#als %here the &eriodi ser#er is sheduled. hoose the &eriod and utili2ation of this ser#er so that all s&oradi 1obs %ill be om&leted by their deadlines and the utili2ation of the s&oradi ser#er is as small as &ossible. Sol+ For simple sporadic ser'er!
0a*/s1.es M" a as we know! a*/s M" 0a*/s1 "M a*/s.es M" a s M" a
"M
This makes sense because o& -obs arri'e e'ery >a> time units and take >a> time units to complete. They will need all a'ailable processor power.
:About the Sporadic Server:
• DS may delay lower-priority tasks. • Sporadic Servers (SS)
rules
ensure
that
each
sporadic
server
(ps, es)
never demands more processor time than the periodic task (ps, es). Sporadic Server in i!ed-"riority Systems: #otations • $: system o% n independent, preemptable periodic tasks. • $&:
subset
o%
periodic
tasks
with
hi'her priorities
than
the
server
priority. • $ $& are either busy or idle. • Server busy interval: an aperiodic *ob arrives at an empty +ueue, the +ueue becomes empty a'ain. • tr: the latest (actual) replenishment time. • t%: the %irst instant a%ter tr at witch server be'ins to e!ecute. • te: the latest e%%ective replenishment time. • At any time t: /01#: be'innin' instant o% the earliest busy interval amon' the latest conti'uous e+uence o% busy intervals o% $& that started be%ore t. /#D:
end
o%
the
latest
busy
interval
in%inity i% the interval ends a%ter t. Simple Sporadic Server
i%
this
interval ends
be%ore t,
• 2onsumption 3ules: At any t 4 tr, bud'et is consumed at the rate o% 5 per unit time until bud'et is e!hausted when 25: the server is e!ecutin' 63 27: the server has e!ecuted since tr and /#D 8 t. • 3eplenishment 3ules: 35: 1nitially when system be'ins e!ecution and each time when bud'et is replenished, bud'et 9 es and tr 9 current time. 37: At time t%, i% /#D 9 t% then te 9 ma!(tr, /01#), i% /#D 8 t% then te 9 t%. #e!t replenishment time is te ps. 3;: a) 1% te ps is earlier than t%, bud'et is replenished as soon as it is e!hausted. b) 1% $ becomes idle be%ore te ps and becomes busy a'ain at tb, bud'et is replenished at min(te ps, tb).
Solutio n s - liu_.htm l
http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-w-
Real Time System by Jane W. S. Liu ha&ter A. Solution
/.A.+ 3 system ontains fi#e 1obs. There are three resoures O, N and . The resoures re$uired of the 1obs are listed belo%. J+ QO86 J6 + 7K7 J- + QN8 J= + QO8- Q8 J@ + QN8= Q86
The &riority Ji is hi!her than the &riority of J1 for i E 1. What are the maimum blokin! times of the 1obs under the non&reem&table ritial setion &rotool and under the &riority eilin! &rotool5
Sol+
=onpreempti'e critical section
b " maxi M (ci) " C b5 " maxi M 5(ci) " C
b$ " maxi M $(ci) " C bC " maxi M C(ci) " C b8 " maxi M 8(ci) " +
/riority ?eiling
Priority (nheritance Protocol Works #ith any priority-driven schedulin( al(orithm Encontrolled priority inversion cannot occur %rotocol does not avoid deadlock /'ternal mechanisms needed to avoid deadlock
ssumption0 ll resources have only one unit
9e!initions0 The priority o! a "ob accordin( to the schedulin( al(orithm is its assi(ned priority t any time t) each ready "ob J is scheduled and e'ecutes at its current priority P 2t3) #hich may di!!er !rom its assi(ned priority and vary #ith time.
%riority (nheritance
The current priority Pl2t3 o! a "ob Jl may be raised to the hi(her priority Ph2t3 o! a "ob Jh
When this happens) #e say that the lo#er -priority "ob Jlinherits the priority o! hi(herpriority "ob Jh) and that Jl e'ecutes at its inherited priority Ph2t3
Schedulin( Rule Ready "obs are scheduled on the processor preemptively in a priority-driven manner accordin( to their current priorities. t its release time t) the current priority P2t3 o! every "ob J is e&ual to its assi(ned priority. The "ob remains at this priority e'cept under the condition stated in the priority-inheritance rule
llocation Rule When a "ob J re&uests a resource R at time t) a3 i! R is !ree) R is allocated to J until J releases the resource) and b3 i! R is not !ree) the re&uest is denied and J is blocked
%riority-7nheritance Rule When the re&uestin( "ob J becomes blocked) the "ob Jl #hich blocks J inherits the current priority P2t3 o! J. The "ob Jl e'ecutes at its inherited priority P2t3 until it releases R t that time) the pri ority o! Jl retur ns to its priority Pl2t83 at the time t8 #hen it ac&uired the resource R.
Solution s- liu_10.html
http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-w-
Real Time System by Jane W. S. Liu ha&ter A.6 Solution 3 system ontains the follo%in! four &eriodi tasks. The tasks are sheduled by the rate /.A.6+ monotoni al!orithm and the &riority eilin! &rotool.
T C(-,9.D@) b C 9.4 T6 C (-.@,.@) b 6 C 9.D@ T- C(?,9.?) b - C 9.4 T= C (9,) bi is the blokin! time of T i. 3re the tasks shedulable 5 &lain your ans%er. Sol+ R ate monotonic algorithm
&or 0T1 " +.D8*$ +.#*$ " +.88 4 0T51 " +.D8*$ .8*$ +.D8*$.8 " +.6# M R,(5) " +.656 Hence! ?ondition &ails. So! by using TG9! N0$1 " +.D8 +.# " .A8 4 $
2Schedulable
N50$1 " .8 +.D8 0$*$1+.D8 " $ 4 $.8
2Schedulable
N$0$.81 " +.A 5x5.D8 .8 $ " C. 4 A
2Schedulable
N$0A1 " +.A .8 $ " A. M A
2 =ot Schedulable
)he Priority Ceiling Protocol Common real-time operatin( systems rely on priority-based) preemptive schedulin(. Resource sharin( in such systems potential ly leads to priority inversion. processes o! hi(h priority can be prevented !rom enterin( a critical section and be delayed by processes o! lo#er priority. Since uncontrolled priority inversion can cause hi(h-priority processes to miss their deadlines) a real-time operatin( system must use resource-sharin(( mechanisms that limit the e!!ects o! priority inversion. The priority ceilin( protocol is one such mechanism. 7t ensures mutual e'clusion and absence o! deadlocks) and minimi+es the len(th o! priority inversion periods. This paper presents a !ormal specication and analysis o! the protocol usin( %S and the ri(orous proo! o! associated schedulability results. The problem #ith the basic protocol is that "ob priorities are not taken into account #hen access to critical sections is (ranted. 7! a semaphore S is !ree) a "ob " e'ecutin( %2S3 obtains access to S) irrespective o! any other "obs already in a critical section. T#o "obs "1 and "; can then lock t#o distinct semaphores S1 and S;. 7! the t#o semaphores are re&uested later on by a "ob k o! hi(her priority than "1 and ";) t#o successive blockin( periods #ill occur. To prevent such a situation) the priority ceilin( protocol en!orces stron(er rules !oraccessin( a critical section. 7! t#o "obs "1 and "; could potentially block a common "ob k via t#o semaphores S1 and S;) the protocol does not (rant S1 to "1 and S; to "; at the same time. :or e'ample) i! "1 has lo#er priority than "; and enters a critical section rst) then the re&uest %2S;3 by "; #ill not be (ranted even thou(h S; may be !ree. To decide #hether it is sa!e to allocate a semaphore S to a "ob ") the protocol must have some in!ormation about the other "obs that
mi(ht re&uest S in the !uture. :or this purpose)each semaphore S is assi(ned a 'ed ceilin( that is e&ual to the hi(hest priority amon( the "obs that need access to S. 7! S is allocated to " then "obs o! priority hi(her than " and lo#er than or e&ual to the ceilin( o! S mi(ht become blocked by ". The rule !or enterin( critical sections is based on the priority o! the re&uestin( "ob and the ceilin( o! the semaphores already locked0 A job j executing P(S) is granted access to S if the priority of j is strictly higher than the ceiling of any semaphore locked by a job other than j. Otherise, j becomes blocked and S is not allocated to j. part !rom the ne# rule !or accessin( semaphores) the priority ceilin( protocol #orks like the basic priority inheritance protocol. "ob k is said to block " i! k has lo#er priority than " and o#ns a semaphore o! ceilin( at least e&ual to the priority o! ". Such a "ob k prevents " !rom enterin( a critical section. 7! " re&uests access to a semaphore) then " becomes blocked and k inherits "8s priority. n essential property o! the protocol is that " cannot have more than one blocker k.
Solution http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-ws - liu_1120.htm l
Real Time System by Jane W. S. Liu ha&ter A.- Solution
/.A.-+
onsider a fied &riority system in %hih there are fi#e tasks Ti, for i C , 6, -, = and @,
%ith dereasin! &riorities. There are t%o resoures O and N. The ritial setions of T,T6, T= and T@ are QN8-, QO8=, QN8@ QO86 and QO89 res&eti#ely. (7ote that -Tdoes not re$uire any resoure.) >ind the blokin! time b i(r) of the tasks. Sol+ /riority ?eiling (with locking time)
*ccess to Shared esources 7n Real Time System) some shared resources must be protected !rom concurrent accesses. The various tasks may demand !or the same resources and this may leads to !ailure o! the system. The Well-kno#n solutions ensurin(
mutual e'clusion e'ists) those are semaphores) mute' locks) etc. Me!ore enterin( a critical section) the "ob e'ecutes a lock operation such as #ait operation on a binary semaphore. t the e'it) an unlock operation is per!ormed such as si(nal operation on a binary semaphore. ultiple-unit resources and multiple-unit resource re&uests can be dealt #ithin the same !rame#ork. *ested critical sections are possible) but the resources must be accessed in a Last-7n-:irst-Kut order ) such that the critical sections must be properly nested. The len(th o! a critical section may include the len(th o! other critical sections 2the case o! nested critical sections3.
esource Con+icts and $locking When the scheduler
esource *ccess Protocols We have seen the importance and the need o! the Resource access protocols) these are the set o! rules that (overn0 When and under #hat conditions each re&uest !or a resource is (ranted o# "obs re&uirin( resources are scheduled The main ob"ective is to avoid unbounded priority inversion and the secondary ob"ective is to reduce the blockin( times as much as possible
Solution
s- liu_231#.html
http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-w-
Real Time System by Jane W. S. Liu ha&ter A.D Solution
/.A.D+ 3 system ontains the follo%in! fi#e &eriodi tasks. The tasks are sheduled rate monotonially. T C (?, -, QO86) T6 C (69, @, QN86) T- C (699, @, QO8- Q8) T= C (69, ?, Q8@ QN8=)
om&are the shedulability of the system %hen the &riority eilin! &rotool is used #ersus the 7PS &rotool. Sol+
=onpreempti'e ?ritical Section
b " 8 b5 " 8 b$ " 8 bC " 8
w(t) " $ 8 " 6 N " 6 M p " A there&ore! T is not schedulable
/riority ?eiling
w(t) " $ $ " A N " A 7 p " A
?ontinue using time
demand analysis! to show that
N5 " 6 7 p5 " 5+ N$ " 85 7 p$ " 5++ NC " 8$ 7 pC " 5+ There&ore! all tasks are schedulable
esource *ccess Control Protocol
Need a set of re,uire'ents -prot ocol. that deter'ine the behavior of scheduler when jobs want access to a co''on resource/ esource contention between various jobs in the syste' 'ay cause higher priority jobs to be blocked by a lower priority job/ )his is k no w n as priority inversion/ )his causes ti'ing ano'alies and higher priority tasks could 'iss their deadl ine/ Deadlock 'aybe caused as result of non0pree'ptive jobs holding serial resources/ 1hen two jobs re,uire two resources2 a possible deadlock situation will arise when each holds one of the two resources2 each waiting for the other job to release the resource/ (t is not possible to prevent priority inversion2 so our goal is to reduce delays caused by priority inversion/ Deadlo ck avoidance is another goal of so'e resource accesscontrol protocols/ 1ait0for0graph is used to 'odel resource contention/ %very serial reusable resource is 'odeled/ %very job which re,uires a resource is 'odeled by vertex with arrow pointing towards the resource/ %very job holding a resource is represented by a vertex pointing away fro' the resource and towards the job/ * cyclic path in a wait0for0graph indicates deadlock/ * 'ini'u' of twosyste' resources are re,uired in a deadlock/
Non0Pree'ptive Critical Section protocol -NPCS.
*ny job re,uesting a resource is always given the resource/ 1hen a job has the resource2 it executes at a priority higher than the priority of other jobs until it co'pletes execution of its critical section/ $ecause no job is ever pree'pted in a syste' using this protocol2 deadlock can not occur in such syste's/
Characteristics o! the *%CS protocol
Si'ple to i'ple'ent Can be used in static priority as well as dyna'ic priority syste's Perfor's well when all critical sections are relatively short %very job2 regardless of its priority can be blocked by any other job
Solution s - liu_11.htm l
http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-w-
Real Time System by Jane W. S. Liu ha&ter A.9 Solution Bi#en a system onsistin! of the follo%in! tasks %hose &eriods, eeution times and /.A.9+ resoure re$uirements are !i#en belo%.
T C (6, 9.=, QO, -8 9.-) T6 C (-, 9.D@, QO, 8 9.-QN, 8 9.=) T- C (?, .9, QN, 8 9.=Q, 8 9.@ QO, 8 9.=) T= C (A, .9, QO, 8 9.@QN, 68 9. Q, 8 9.=)
There are - units of O, 6 units of N and unit of . The tasks are sheduled by ;> al!orithm and the stak based &rotool.
a) >ind the &reem&tion eilin! of eah resoure and the maimum blokin! time for eah task. Sol+ /reemption ?eilings
b) 3re the tasks shedulable aordin! to the earliest deadline first al!orithm5 Why 5
Sol+
Schedulability test
T T5 T$ TC
(e b) * p i(ei * pi) " (+.C +.C*5 (+.D8+.8)*$ *A *6 +.C*5 +.D8*$ (+.8)*A *6 +.C*5 +.D8*$ *A (+.8)*6
+.8)*5 +.D8*$ *A *6 : +.#5 : +.# : +.658 : +.6+
There&ore! all tasks are schedulable by EGF
Stack esource Policy-SP.
/'tend de!inition o! priority ceilin(0 7n priority ceilin( priorities are replaced by preemption levels. This allo#s /9: priorities to be handled #ithout re&uirin( to recompute ceilin(s at run time. Cceilin(s are de!ined !or multiunit resources) subsumin( both binary semaphores and read<#rite lock
bstract ceilin(s i! J is currently e'ecutin( or can preempt the currently e'ecutin( "ob) and may re&uest an allocation o! R that #ould be blocked directly by the outstandin( allocation o! R) then ARB ? P 2J3
Speci!ic ceilin(s ARBR 5 ma'2U∪P2J3 Y R O ZR 2J3U3 R units o! R available. ZR2J3 is the ma'imum num ber o! units o! R that "ob J may need to hold at any one time
Current ceilin( P 5 ma'2ARiBY i 5 1)[)mU ∪P2JcU3 i! there8re no "obs currently e'ecute) P 5 the SR% re&uires that a "ob e'ecution re&uest J be blocked !rom startin( e'ecution until P O P2J3. Knce J has started e'ecution) all subse&uent resource re&uest by J are (ranted immediately doesn8t restrict the resource ac&uirin( order) and allocate only #hen re&uests. release resources #hen they are not need. J is !ree to preempt until J actually re&uests enou(h o! R to block J 2#ithout bein( blocked3.
Mlockin( properties o! the SR% 7! no "ob J is permitted to start until P8 O P2J3 5F 2a3 *o "ob can be blocked a!ter it starts 2b3 There can be no transitive blockin( or deadlock 2c3 7! the oldest hi(hest-priority "ob is blocked) it #ill become unblocked no later than the !irst instant that the currently e'ecutin( "ob isn8t holdin( any nonpreemptable resources.
Solution s - liu_12.htm l
http://targetiesnow.blogspot.in/2013/11/real-time-system-by-jane-w-