Aperiodic Task Scheduling Gerhard Fohler Mälardalen University, Sweden gerhard.fohler@mdh.se Real-Time Systems Gerhard Fohler 2005
Non Periodic Tasks So far periodic events and tasks what about others? Sporadic (aperiodic, but minimum interarrival time) worst case: all sporadic tasks arrive with highest frequency (with minimum time between arrivals) all other arrival patterns less demanding if we can schedule worst case, we can schedule all other worst case - minimum interarrival time - like periodic task assume sporadic tasks as periodic for schedulability test Real-Time Systems Gerhard Fohler 2005 2
Aperiodic (no limitations on arrival times known) soft: without deadline not much to do from scheduling view firm: with deadline (worst case execution time needs to be known as well) usually all or nothing semantic: when we start task, we want that it runs until completion; else we don t start Real-Time Systems Gerhard Fohler 2005 3
Background Services Fixed priority scheduling, rate monotonic What is the minimum we can do for aperiodic tasks in a periodically scheduled system? Background service: execute aperiodic tasks when no periodic ones are executing no disturbance of periodic tasks (and their feasibility) simple run-time mechanisms queue for periodics queue for aperiodics - FCFS no guarantees Real-Time Systems Gerhard Fohler 2005 4
Polling Server Background service lives from left overs of periodic tasks, without guarantees If enough idle time, ok long response times, although faster service possible How can we provide that at least a certain amount of processing goes to aperiodic tasks? Server task periodic task, whose purpose is to service aperiodic requests as soon as possible period T s computation time C s is called capacity of the server Real-Time Systems Gerhard Fohler 2005 5
Polling server algorithm at periods T s server becomes active and serves aperiodic requests with its capacity C s no aperiodic activities - not execute, waits for next period, capacity lost based on rate monotonic Lehozcky, Sha, Strosnider, Sprunt 987, 989 Real-Time Systems Gerhard Fohler 2005 6
Example Polling Server two tasks, 2 C i T i 4 2 2 6 server C s =2 T S =5 Real-Time Systems Gerhard Fohler 2005 7
server Cs=2 TS=5 2 aper. c=2 c= c=2 c= no no aper cap 0 2 4 6 8 0 2 4 6 8 20 22 24 26 28 time C s 2 Real-Time Systems Gerhard Fohler 2005 8
Aperiodic Guarantee Aperiodic guarantee hard aperiodic task T a, C a, D a worst case: aperiodic request misses the server task has to wait until next instance if C a <= C s, aperiodic request completed within two server periods (one for waiting, one for executing) 2*T s <= D a arbitrary execution times: T s + C a /C s T s <= D a average response time not very good! Real-Time Systems Gerhard Fohler 2005 9
Further FPS Server Algorithms Deferrable Server(Lehozcky, Sha, Strosnider 987, 995) lower bound for periodic tasks Priority exchange (Lehozcky, Sha, Strosnider 987) Sporadic server Sprunt, Sha, Lehozcky 989 replenishes capacity only after aperiodic execution optimum algorithm does not exist! Tia, Liu, Shankar 995 proof that with static priority assignment, no algorithm exists to minimize response time Real-Time Systems Gerhard Fohler 2005 0
Dynamic Priority Servers EDF based Dynamic priority exchange server Spuri, Buttazzo 994, 996 like rate monotonic priority exchange, but for EDF Dynamic sporadic server Spuri, Buttazzo 994, 996 Earliest deadline late server Chetto, Chetto 989 Real-Time Systems Gerhard Fohler 2005
Total bandwidth server Spuri, Buttazzo 994, 996 response time dependent on server period: shorter periods have shorter response times but higher overhead how else shorter response times? change the deadline of the aperiodic to earlier time (its EDF here, so it will get serviced earlier) but make sure that total load of aperiodics does not exceed maximum value (bandwidth) U s Real-Time Systems Gerhard Fohler 2005 2
How can we calculate minimum deadline for U S? assume we have all CPU for us: dl = C U U t C t+c 0.5 U S t C t+2*c Real-Time Systems Gerhard Fohler 2005 3
k th aperiodic request arrival time r k computation time c k deadline d k server utilization U S d k = max( r k, d k- ) + C k /U s d 0 = 0 uses all bandwidth of server very simple run-time mechanism no extra server task schedulability U p + U s <= Sum of periodic load and bandwidth of server less or equal. Real-Time Systems Gerhard Fohler 2005 4
Example Total Bandwidth Server periodic tasks (3,6), 2 (2,8) TBS U s = - U p = 0.25 2 aper. dl = 3+/0.25=7 2 dl 3 = max(4,7)+/0.25=2 0 2 4 6 8 0 2 4 6 8 20 22 24 26 28 time dl 2 = 9+2/0.25=7 Real-Time Systems Gerhard Fohler 2005 5
Total Bandwith Server - Comments based on U s not actual periodic load worst case c Real-Time Systems Gerhard Fohler 2005 6
Total Bandwith Server - Comments TBS assigns deadlines based on maximum U s (not actual load) d k = max( r k, d k- ) + C k /U s, d 0 = 0 U s =0.25 aper. dl = 6+/0.25=4 0 2 4 6 8 0 2 4 6 8 20 22 24 26 28 time Real-Time Systems Gerhard Fohler 2005 7
TB* Buttazzo, Sensini - 997 assigns deadlines d k first according to TBS then shortens, as much as periodics allow new d = f k k finishing time according to EDF schedule, including periodics apply recursively maintains schedulability, since order maintained complexity, many steps Real-Time Systems Gerhard Fohler 2005 8
Constant Bandwidth Server Abeni and Buttazzo, 998 designed for multimedia applications sporadic (hard) tasks soft tasks: mean execution, interarrival times, not fixed periodic tasks assign maximum bandwidth of CPU to each soft task handles overload of aperiodics limited by assigned bandwidth might slow down, but not impair effect other tasks EDF based Real-Time Systems Gerhard Fohler 2005 9
CBS Definitions task i sequence of jobs J i,j r i,j request, arrival time of the j th job of task I hard task (C i,t i ) C i worst case execution time T i minimum interarrival time deadline equal to next period: d i,j = r i,j + T i soft task (C i,t i ) C i mean execution time T i desired interarrival time soft deadline equal to next period: d i,j = r i,j + T i Real-Time Systems Gerhard Fohler 2005 20
c S budget (Q S,T S ) Q S maximum budget T S period of server U S = Q S/ T S server bandwidth d S,k deadline associated to server initial d S,0 =0 job J i,j comes in, is served, assigned dynamic deadline d i,j equal to current server deadline d S,k job executes, server budget c s decreased Real-Time Systems Gerhard Fohler 2005 2
c S =0: budget recharged to maximum Q S new server deadline: d s,k+ =d s,k +T S J i,j arrives, CBS active (jobs pending): put in queue J i,j arrives, CBS idle: c S (d s,k - r i,j )*U S : new deadline d s,k+ = r i,j + T S c S recharged to Q S else job served with last server deadline d s,k job finishes: next job in queue at any time, job assigned last deadline generated by server Real-Time Systems Gerhard Fohler 2005 22
Example CBS (2,3) hard 2 soft c =3 c s (d s,0 - r )*U S :d s, =r +T S =9 c 2 =2 c s =<(23-7)*2/7=2/7 no new deadline server active - queue c 3 = CBS r r 2 r 3 c S = 0:d S,2 =d s, +T S =6 c S = 0:d S,3 =d s,2 +T S =23 (2,7) 0 2 4 6 8 0 2 4 6 8 20 22 24 26 28 time Real-Time Systems Gerhard Fohler 2005 23
limits impact harm by ill behaved aperiodics, e.g., exec time overrun various improvements several servers capacity exchange feedback control.. Real-Time Systems Gerhard Fohler 2005 24
Articles TBS: Spuri, Buttazzo Efficient Aperiodic Service under Earliest Deadline Scheduling Proceedings of the 5th IEEE Real-Time System Symposium (RTSS 94), Portorico, pp. 2-2, December 994 CBS: L. Abeni and G. Buttazzo, "Integrating Multimedia Applications in Hard Real-Time Systems", Proceedings of the IEEE Real-Time Systems Symposium, Madrid, Spain, pp. 4-3, December 998. Real-Time Systems Gerhard Fohler 2005 25
Schedulability Analysis First show that aperiodic load executed not exceeds U S of server Lemma: In each interval of time [t,t 2 ], if C ape is the total execution time demanded by aperiodic requests arrived at t or later and served with deadlines less than or equal to t 2, then Proof: by definition: C ape (t 2 - t ) U S C ape C k t rk, dk t 2 Real-Time Systems Gerhard Fohler 2005 26
TB* uses periodic interference can now calculate it (formulae for completeness only) I f (t, d k s) = n i max 0, d s k next T i _ r ( t) i C i next_r i (t) time at which next instance of I after t starts Real-Time Systems Gerhard Fohler 2005 27
TBS assigns deadlines in increasing order, therefore there must exist two aperiodic requests with indeces k and k 2 such that k C ape k k 2 k C k k k t 2 rk, d k t 2 k 2 C k C [ dk max( rk, dk k k k )] * U [ max( r, d k k k d )]* U 2 S S ( t t ) * 2 U S Real-Time Systems Gerhard Fohler 2005 28
Proof main result: Theorem: Given a set of n periodic tasks with processor utilization U p and a TBS with processor utilization of U S, the whole set is schedulable by EDF if and only if U p + U S Proof: If: assume U p + U S plus overflow at time t overflow preceded by continuous utilization from a point t on (t < t), only instances of tasks ready at t or later and having deadlines less than or equal to t are run C total execution time demanded by these instances since there is overflow at t: t - t < C Real-Time Systems Gerhard Fohler 2005 29
Real-Time Systems Gerhard Fohler 2005 30 we also know that ape i n i i C C T t t C * ' S i n i i U t t C T t t ) * ( * ' ' ) )*( ( ' U p U S t t it follows: U p +U S > # contradiction
only if: assume aperiodic request enters periodically with period T S and execution time C S =T S U S, then server behaves like periodic task total utilization of processor is then U p +U S if task set schedulable: U P +U S Real-Time Systems Gerhard Fohler 2005 3