Dsadvantages of cyclc TDDB47 Real Tme Systems Manual scheduler constructon Cannot deal wth any runtme changes What happens f we add a task to the set? Real-Tme Systems Laboratory Department of Computer and Informaton Scence Lnköpng Unversty, Sweden Denes the advantages of concurrent programmng Whch? The lecture notes are partly based on lecture notes by Caln Curescu, Smn adjm- Tehran, Jörgen Hansson, Anders Törne. They also loosely follow Burns and Wellng book Real-Tme Systems and Programmng Languages. These lecture notes should only be used for nternal teachng purposes at Lnköpng Unversty. 29 pages 2 of 29 States of a process Prorty-based schedulng Every task has an assocated prorty Run task wth the hghest prorty At every schedulng decson moment Examples Rate Monotonc (RM) Statc prorty assgnment Earlest Deadlne Frst (EDF) Dynamc prorty assgnment And many others 3 of 29 4 of 29 Schedulablty Test Test to determne whether a feasble schedule exsts Suffcent + f test s passed, then tasks are defntely schedulable - f test s not passed, we don t know ecessary + f test s passed, we don t know - f test s not passed, tasks are defntely not schedulable Exact suffcent & necessary at the same tme Rate Monotonc (RM) 5 of 29 6 of 29
Assumpton Rate Monotonc All tasks have ther ntal release at tme 0 Each process s assgned a (unque) prorty based on ts perod; the shorter the perod, the hgher the prorty Assumes the Smple task model Fxed prorty schedulng Preemptve Unless stated otherwse 7 of 29 8 of 29 Example 1 Example 1 (cont d) Assume we have the followng task set OBS: not scheduled yet Scheduled wth RM 9 of 29 10 of 29 Schedulablty test for RM Example 2 Suffcent, but not necessary: = 1 C T 21 / 1 Taskset P1 P2 P3 Perod (T) 20 50 30 WCET (C) 7 10 5 ecessary, but not suffcent: = 1 C T 1 11 of 29 12 of 29
Harmonc perods Example 3 Taskset: Exact schedulablty test for RM f perods are harmonc: = 1 C T 1 Gantt chart: 13 of 29 14 of 29 The frst tme s the hardest Exact schedulablty test Theorem If all tasks meet ther frst deadlne, then they wll meet all future ones. Proof: paper by Lu and Layland, 1973 Why? The scedulablty of a gven taskset for RM can be decded by: Drawng a schedule Dong a response tme analyss Complexty: Pseudo-polynomal tme 15 of 29 16 of 29 Response tme analyss Optmalty of schedulng algorthms Tasks suffer nterference from hgher prorty tasks Response tme: the tme that passes snce the task s released and untl t fnshes R =C +I R =C Iteratve formula for calculatng response tme n+ w 1 =C w n j hp T j C j j hp R T j C j A scheduler s optmal f t always fnds a schedule when a schedulablty test ndcates there s one. Burns, 1991 An optmal schedulng algorthm s one that may fal to meet a deadlne f no other schedulng algorthm can meet t. Stankovc et al., 1995 An optmal schedulng algorthm s guaranteed to always fnd a feasble schedule, gven that a feasble schedule does exst. Hansson, 1998 17 of 29 18 of 29
Optmalty of RM What to do f not schedulable Change the task set utltsaton Rate Monotonc s optmal among fxed prorty schedulers by reducng C code optmsaton faster processor If we assume the Smple Process Model for the tasks Increase T for some process If your program and envronment allows t 19 of 29 20 of 29 RM characterstcs Easy to mplement. Drawback: May not gve a feasble schedule even f processor s dle at some ponts. Earlest Deadlne Frst (EDF) 21 of 29 22 of 29 Earlest Deadlne Frst (EDF) Schedulablty test for EDF Always runs the process that s closest to ts deadlne. Dynamc prorty schedulng Evaluated at run-tme What are the events that should trgger a prorty reevaluaton? Assumes the Smple task model Actually more relaxed: D < T Utltsaton test ecessary and suffcent Or exact test = 1 C T 1 Preemptve Unless stated otherwse 23 of 29 24 of 29
Optmalty of EDF Example 4 EDF s optmal among dynamc prorty schedulers Consder followng task set: P1 P2 WCET (C ) 2 4 Deadlne (D = T ) 5 7 If we assume the Smple Process Model for the tasks Is t schedulable wth EDF? Or a more relaxed one where D < T Is t schedulable wth RM? 25 of 29 26 of 29 Domno Effect EDF vs. RM EDF can handle tasksets wth hgher processor utlsaton. Example 4 not schedulable wth RMS! EDF has smpler exact analyss RMS can be mplemented to run faster at run-tme Depends on the OS But they usually lke fxed prortes more 27 of 29 28 of 29 Readng materal Dynamc Schedulng Chapter 13 n Burns & Wellngs Chapter 4 n Butazzo for the proofs of suffcent condton and optmalty 29 of 29 30 of 29