ff32659e1faa52ffcaaf57db5e54d987.ppt
- Количество слайдов: 86
Aperiodic Job Scheduling Real-Time Computing 羅習五 本份投影片大量參考交通大學 張立平教授的投影片 1
rejection Sporadic Jobs Acceptance Test Job-basis rejection Periodic Task Acceptance Test Processor Task-basis Aperiodic Jobs 2
Aperiodic and Sporadic Jobs • Definition – Jobs of apreiodic and sporadic tasks • Inter-arrival times are arbitrary – Aperiodic Jobs • Assigned to either no deadlines or soft deadlines – Sporadic Jobs • Assigned to hard deadlines 3
Aperiodic and Sporadic Jobs • Handling of jobs – Apreiodic jobs • In a best-effort fashion • Accept anyway – Sporadic jobs • Accept jobs if deadline satisfaction is guaranteed • Otherwise, reject jobs 4
Aperiodic and Sporadic Jobs • Correctness – All accepted sporadic jobs and periodic jobs meet their respective deadlines 5
Aperiodic and Sporadic Jobs • Optimality – Apreiodic jobs • Minimizing the average response time of jobs – Sporadic jobs • Accept jobs if and only if they can be scheduled by some means 6
Aperiodic and Sporadic Jobs • What we are going to talk about are… – How to handle aperiodic jobs • Reserve a portion of CPU power for aperiodic jobs in fixedpriority and deadline-driven systems • Try to deliver high responsiveness • Schedulability of periodic tasks must not be affected – How to handle sporadic jobs • Employ mechanism proposed for the above • Test whether deadlines of sporadic jobs can be met 7
Handling Aperiodic Jobs • Approaches – Background execution • Improvement: slack stealing – Interrupt-driven execution • Improvement: slack stealing – Polled execution • Improvement: Bandwidth-preserving servers 8
Handling Aperiodic Jobs • Terminology (1/3) – Periodic jobs • Jobs of periodic tasks – Server • A task servicing sporadic jobs • Can be either periodic servers or sporadic servers • Characterized by (c, p) – Don’t confuse with a periodic task, a server does not stands for a periodic task • c budget, c/p server size 9
Handling Aperiodic Jobs • Terminology (2/3) – Backlogged • A server is backlogged if there are some ready jobs in its queue – Eligible • A server is eligible if it has budget and is backlogged 10
Handling Aperiodic Jobs • Terminology (3/3) – Budget consumption rules • Define how budget is consumed when servicing jobs – Budget replenishment rules • Define how budget is replenished – Server execution • When a server is eligible, it is scheduled with other periodic tasks as if it were a periodic task • When budget is exhausted, the server is suspended immediately 11
Part A: Server Design & the handling of aperiodic jobs
Handling Aperiodic Jobs • Background execution – Handle aperiodic jobs whenever there is no periodic jobs to execute • Extremely simple • Always produce correct schedule • Poor response time 13
Background Execution 0. 1 Response time=7. 7 0. 8 14
Handling Aperiodic Jobs • Interrupt execution – An obvious extension to background execution – On arrivals, aperiodic jobs immediately interrupts the currently running periodic job – Fastest response time – Schedulability of periodic jobs can be damaged 15
Interrupt Execution * Execution time=2. 1 16
Handling Aperiodic Jobs • Slack stealing – To postpone periodic jobs when it is safe to do so – Algorithmically simple, but hard to implement 17
Slack Stealing A 18
Handling Aperiodic Jobs • Polled execution – A purely periodic task (polling server) to serve a queue of aperiodic jobs – When the polling server gains control of the CPU, it services aperiodic jobs in the queue – If the queue becomes empty, the polling server suspends immediately • The queue is not checked until the next polling period 19
The polling server loses all its budget at time 0, since there is no ready aperiodic jobs (0. 5, 2. 5) 0 0. 5 0. 3 RMS Aperiodic job A arrives at time 0. 1 20
Handling Aperiodic Jobs • Polling servers are easy to implement and are analytically simple • However, a polling server loses all its budget once the queue is empty – If we can preserve the residual budget, aperiodic jobs can be serviced and their response time can be shortened 21
Handling Aperiodic Jobs • Bandwidth-preserving servers – Deferrable servers – Sporadic servers – Constant utilization servers, total bandwidth servers, weighted fair-queuing servers • These servers aim at improving responsiveness by means of: – Preserving budget whenever possible – Aggressively replenish 22
Deferrable Servers • Let a deferrable server be denoted by (cs, ps) • Consumption rules: – Budget is consumed at rate of 1 whenever the server services aperiodic jobs • Replenishment rules: – Budget is set to cs at k*ps, for k=0, 1, 2, … 23
Deferrable Servers (1, 3) (1. 5, 3. 5) (0. 5, 6. 5) Preserving budget Fixed-priority: priority TDS T 1 T 2 24
Deferrable Servers (1, 3) (1. 5, 3. 5) (0. 5, 6. 5) Preserving budget Deadline-driven: the deadline of a server job is the next replenishment time 25
Deferrable Servers • Because budget is preserved, aperiodic jobs can conflict with any periodic jobs at any time – Differently, jobs of a purely periodic task only arrive at the beginning of every period • Does critical instants for tasks of a fixedpriority system in which there is a deferrable server exists? 26
Deferrable Servers • The below figure shows a scenario in which a deferrable server interferes low-priority tasks most (aka double hit) DS becomes backlogged c. S p. S budget 27
Deferrable Servers • Theorem: Critical instant of task Ti (Let the deferrable server TDS have the highest priority) 28
Deferrable Servers • Response time analysis – For each i, task Ti is schedulable if Ri, j converges no later than Pi 29
Deferrable Servers • Response time analysis is accurate, but can we have a polynomial time test like the utilization-bound test? • Bad news: – There is no know utilization bound if a deferrable server is of an arbitrary priority • Good news (not so good): – Consider a system of n independent, preemptible periodic tasks and ps<p 1<…<pn<2 ps and pn>ps+cs [Lehoczky 87] 30
Ouch, it is quite low… Utilization bound when Us = 1/3 31
Deferrable Servers • Yet another good news: – We can still make use of the Liu-and-Layland utilization bound if some conservative considerations are taken 32
Deferrable Server • If the deferrable server TDS is of an arbitrary priority, it may impose up to one additional Cs on feasible intervals of jobs of some lowpriority task Ti c. S p. S …… ci pi 33
Deferrable Server • Task set {T 1, …, Tm, TDS, Tm+2, …Tn} – {T 1, …, Tm} is schedulable if ∑ci/pi≦U(m) – For i=(m+1)…n, the reminder of the task set is schedulable if – Let’s try T 1=(0. 6, 3), TDS=(0. 8, 4), T 3=(0. 5, 5), T 4=(1. 4, 7) 34
Deferrable Servers • Why can we treat the additional cs as “extra blocking time” of Ti? ? ? TDS Ti Ti Schedulable schedulable 35
Deferrable Servers • Schedulability of a deadline-driven system with a deferrable server – Consider task set {T 1, …, Tn}U{(cs, ps)} • Let t be the deadline of a job of a periodic task • Let t- (<t) be the latest time instant when the CPU is idle or is executing jobs with deadline later than t • Consider time interval (t-, t], we are interested in the maximum computation time demand from periodic tasks and the deferrable server 36
Deferrable Servers • Deadline-driven systems – The maximum CPU time demanded by the deferrable server in time interval (t-, t] is The last job of es does not affect jobs of deadline no later then t due to EDF discipline Cs ? The maximum occurs when the term inside the floor function is an integer 37
Deferrable Servers • Deadline-driven systems – The maximum CPU time demanded by periodic jobs is Similarly, the maximum happens when the term inside the floor function is a integer 38
Deferrable Servers • If the total CPU time demanded by periodic jobs and apreiodic jobs exceeds t-t-, the taskset is unschedulable! • Diving both sides of the inequality and then Invert the above statement, we have theorem: 39
Deferrable Servers • A deadline-driven system with a deferrable server is schedulable if [Ghazalie 95] 40
Bandwidth-Preserving Servers • Deferrable servers • Sporadic servers • Priority-exchange servers • Constant utilization servers and total bandwidth server 41
Sporadic Servers • Deferrable servers have simple rules for budget consumption and replenishment, but they impose extra delays on periodic tasks – Double hit exists both in priority-driven and deadline-driven scheduling • Schedulability tests for periodic systems with deferrable servers are quite complicated 42
Sporadic Servers • Sporadic servers are designed to improve over deferrable servers – Schedulability test for periodic systems with sporadic servers is very simple – However, nothing always wins. Sporadic servers have complicated consumption and replenishment rules. 43
Sporadic Servers • Design guideline: a sporadic server never demand processor time more than a periodic task (c, p) does in any time interval – Sporadic servers can be replaced with corresponding periodic tasks for schedulability test 44
Sporadic Servers • A sporadic server can be characterized by (c, p) – Note again that a sporadic server is not a periodic task! • Different designs of sporadic servers exist, aiming at – preserving server budget as long as possible, and – replenishing server budget as early as possible 45
Sporadic Servers • Simple sporadic servers in fixed-priority systems 46
Sporadic Servers • Consumption rules 47
Sporadic Servers • Fact A: if a periodic task is schedulable in a fixedpriority system, then all its jobs are schedulable if their inter-arrival times are not shorter than its task period – Based on this fact, budget can be preserved for a long period of time D D 48
Sporadic Servers • Fact B: when a low-priority job is delayed by a highpriority job, the produced schedule is the same as that produced by the two jobs arriving at the same time – Based on this fact, budget can be replenished more aggressively H H L L H L 49
(0. 5, 3) (1. 0, 4) (1. 5, 5) (4. 5, 19) FA FA 50
51
Sporadic Servers • An idle simple sporadic server consumes its budget as all high-priority tasks are idle – Actually no aperiodic jobs are serviced, the consumed budget is wasted! – For further improvement, a sporadic server could be split into chunks [Sprunt 1989] • One “chunk” emulates a smaller sporadic server with the same “period” 52
Sporadic Servers • Fact C: Let T be a periodic system. If is schedulable then _ is also schedulable, provided that _ 53
Sporadic Servers • Combining Fact A and Fact C Of course, chunks can be split and merged whenever needed 54
(0. 5, 3) (1. 0, 4) (1. 5, 5) (4. 5, 19) [Sprunt] 55
Sporadic Servers • Response times in simple Sporadic Servers – A 1: 5. 5, A 2: 14, A 3: 19. 5 • Response times in Sprunt Sporadic Servers – A 1: 5. 5, A 2: 14, A 3: 19. 5, A 4: 7 56
Sporadic Servers • Note that previous slides about sporadic servers are for fixed-priority systems • In deadline-driven systems, both the concepts of simple sporadic servers [Liu] and “chunk” sporadic servers [Ghazalie] are still applicable – They are very complicated though 57
Sporadic Servers • Discussions – DS: simple cons/repl rules, complicated schedulability test – SS: simple schedulability test, complicated cons/repl rules – If you are a system engineer, which one will you take?
Bandwidth-Preserving Servers • Deferrable servers • Sporadic servers • Priority-exchange servers • Constant utilization servers and total bandwidth server 59
Priority-Exchange Servers TH TS TL 60
Priority-Exchange Servers • Again, arithmetically simple, but extremely hard to implement – May require hardware acceleration • We shall then see the elegance and beauty of bandwidth-preserving servers for deadlinedriven systems 61
Bandwidth-Preserving Servers • • Deferrable servers Sporadic servers Priority-exchange servers Constant utilization servers and total bandwidth server 62
Constant Utilization Servers • Let a sporadic job is characterized by arrival time a, execution time c, deadline d – Define its density as • Theorem: A system of independent periodic jobs is schedulable if the total density of tasks is no larger than 1 at any time instant – Direct follow from the proof of EDF 63
Constant Utilization Servers • A sporadic task is of a stream of sporadic jobs • Given a time point t, and ai≤t ≤ di for sporadic job Ji, – ci/(di-ai) is referred to as the instantaneous utilization contributed by job Ji at time instant t 64
Constant Utilization Servers • Prerequisite: – All periodic and sporadic jobs must be completed by the arrival of their next successive jobs • Corollary: A periodic system and a collection of sporadic tasks are schedulable by EDF if the sum of the total utilization of the former tasks and the total instantaneous utilization of the latter tasks is no greater than 1 at any time – Directly follows from the last theorem 65
Constant Utilization Servers • Consumption rules is simple: A server consumes its budget only when it executes • Replenishment rules: as follows [Spuri 96] 66
Constant Utilization Servers • The instantaneous utilization of every sporadic job equals to the server size, as is its name • Budget is replenished only at the deadlines of jobs – As indicated in rule R 2(a) Pitfall: A sporadic job may have two “deadlines”: • The deadline comes with the job da • The deadline assigned by CUS algorithm db The job might not be fulfilled in time if db is later than da 67
68
Total Bandwidth Servers • A CUS replenishes its budget only at the deadlines of aperiodic jobs – A newly arriving job has to wait until the deadline of the lastest aperiodic job, even if the server is currently idle • Is it possible to advance the replenishment? – Yes: total bandwidth servers 69
Total Bandwidth Servers • Consumption rules: the same as those of CUS • Replenishment rules: Instantly replenish server budget! [Deng 97] 70
Total Bandwidth Servers CUS: c 2 c 1 d 1 t d 2 2 nd job arrives TBS: c 1 t c 2 d 1 2 nd job arrives d 2 Budget is replenished as the 2 nd job arrives, and c 2 is associated with deadline d 2 71
Total Bandwidth Servers • Correctness of TBS: – Jobs affected by the early replenishment • Only those dj > d 2 • What about those dj<d 2 or dj<d 1? dj j c 1 t c 2 d 1 d 2 2 nd job arrives 72
Total Bandwidth Servers • CUS/TBS are two good approaches for bandwidth partition • Aperiodic jobs serviced by different servers would have an illusion that they are serviced by different CPUs with reduced power – The concept extends to open system 73
Part B: Checking Deadlines for Sporadic Jobs
Scheduling Sporadic Jobs • So far we discussed many techniques to serve aperiodic jobs in periodic systems • While servers service aperiodic jobs in the best -effort fashion, the servers have to check the deadlines of sporadic jobs – Newly arriving sporadic jobs are rejected if the server found their deadlines unsatisfiable 75
Scheduling Sporadic Jobs: Deadline-driven systems (EDF) • CUS/TBS – Compare • (d 1) the deadline of the sporadic job • (d 2) the deadline assigned by server algorithm – If d 1<=d 2, then accept • If not using CUS/TBS – Applying the density theorem for checking 76
Scheduling Sporadic Jobs: Deadline-driven systems (EDF) • If the total utilization of periodic tasks is Δ, then the total density of sporadic jobs should not be larger than 1 - Δ at any time • Let a sporadic job be denoted by Si(r, c, d) – r: arrival time of the job – c: computation time demand – d: deadline of the job 77
Scheduling Sporadic Jobs: Deadline-driven systems (EDF) • Acceptance test of the first sporadic job – Accept if c/(d-r)≦ 1 -Δ, otherwise reject – Two time intervals are created • I 1=[r, d) – Density (of sporadic jobs) is Δs, 1= c/(d-r) • I 2=[d, ∞) – Density is Δs, 2=0 78
Scheduling Sporadic Jobs: Deadline-driven systems (EDF) • Acceptance test of the Sn(r, c, d) sporadic job (not the first sporadic job) – Suppose that there are many time intervals I 1, I 2, …, In • Let I 1 starts with the current time – Suppose that Il contains the deadline d of Sn – Sn is accepted if for all k=1, 2, …l (why? ) 79
Scheduling Sporadic Jobs: Deadline-driven systems (EDF) • Acceptance test of the Sn(r, c, d) sporadic job (not the first sporadic job) – If Sn is accepted, time intervals become I 1, I 2, …, Il, 1, ll, 2, ll+1, …, ln – Δs, k are incremented by c/(d-r), for all k=1…l • Admission-control time complexity: O(Ns) – Ns: the number of pending (and admitted) sporadic jobs 80
0. 45 0. 35 Overflow, so it is rejected. 0. 6 81
Scheduling Sporadic Jobs: Priority-Driven Systems (RM) • The concept of sporadic server: – “the server (cs, ps) receives at most cs units of time every ps units of time” • The first sporadic job if is accepted 82
Scheduling Sporadic Jobs: Priority-Driven Systems (RM) • Acceptance test of job – stands for the remaining execution time of sporadic job Sk – If succeed, proceed to the next step 83
Scheduling Sporadic Jobs: Priority-Driven Systems (RM) • Check if for Sk, whose deadline is after ds, i and may be adversely affected by the acceptance of Si – This step differs from that in deadline-driven systems! • If both the two steps succeeds, Si is accepted 84
Summary • Serving aperiodic/sporadic jobs in periodic system – Priority-driven systems (DS, SS) – Deadline-driven systems (TBS, CUS) • One major approach for server design is to emulate a periodic task – Budget should be retain as long as possible – Budget should be replenished as soon as possible • Aperiodic jobs are served in best-effort fashion • Acceptance of sporadic jobs should be tested 85
r d density=2/4 2 r d 1. 5 density=1. 5/3 1. 5 r d 3 3 density=3/6 If we remove the density of the top job and accept the middle job, then the bottom job will miss its deadline! 86
ff32659e1faa52ffcaaf57db5e54d987.ppt