CHAPTER 7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems Assumptions Assumptions There is only one processor The periodic, aperiodic, and sporadic tasks are independent each other Every job can be preempted at any time We do not make any assumptions on the interrelease-times and execution times of aperiodic tasks Most algorithms do not even require the knowledge of the execution times of aperiodic tasks after they are released In contrast, we assume that the parameters of each sporadic job become known after it is released Two alternatives for sporadic jobs which missed their deadlines to reject the sporadic jobs that cannot complete in time, or to accept all sporadic jobs and allow some of them to complete late © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Assumptions - continued We assume that the operating system maintains the priority queues rejection Sporadic Jobs Acceptance Test Processor Periodic Jobs Aperiodic Jobs Fig. 7-1 Priority queues maintained by the operating system © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Alternative Approaches Background and Interrupt-Driven Execution versus Slack Stealing According to the background approach, aperiodic jobs are scheduled and executed only at times when there is no periodic or sporadic job ready for execution This method always produces correct schedules, and simple to implement However, the execution of aperiodic jobs may be delayed and their response times prolonged unnecessarily (see Fig. 7-2(a)) An obvious way to make the response times of aperiodic jobs as short as possible is to make their execution interrupt-driven Whenever an aperiodic job arrives, the execution of periodic tasks are interrupted, and the aperiodic job is executed If aperiodic jobs always execute as soon as possible, periodic tasks may miss some deadlines The obvious solution is to postpone the execution of periodic tasks only when it is safe to do so Algorithms that make use of the available slack times of periodic and sporadic jobs to complete aperiodic jobs early are called slack-stealing algorithms © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Alternative Approaches - continued 3 6 9 Background 7.8 0.8 0.1 Fig. 7-2(a) Background execution with © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Alternative Approaches - continued Polled Execution versus Bandwidth-Preserving Servers A poller or polling server is a periodic task The poller is ready for execution periodically at integer multiples of and is scheduled together with the periodic tasks in the system When it executes, it examines the aperiodic queue If the queue is nonempty, it executes the job at the head of the queue The poller suspends its execution or is suspended by the scheduler by either when it has executed for units of time or when the aperiodic job queue becomes empty, whichever occurs sooner We call a task that behaves more or less like a period task and is created for the purpose of executing a aperiodic jobs a periodic server A poller is a kind of periodic server The parameter is called the execution budget (or simply budget) The ratio is the size of the server Different kinds of periodic servers differ in how the server budget changes when the server still has budget bur the server is idle As an example, the budget of a poller becomes exhausted instantaneously whenever the poller finds the aperiodic job queue empty (see Fig.7-2(b)) © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Alternative Approaches - continued 2.5 5.3 7.5 10.0 3 6 9 5 10.0 0.8 0.1 Fig. 7-2(b) Poller execution with and © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Alternative Approaches - continued Fig.7-2(b) shows the shortcoming of the polling approach If we can preserve the execution budget of the poller when it finds an empty queue and allow it to execute later in the period if any aperiodic job arrives, we may be able to shorten the response times Algorithms that improve the polling approach in this manner are called bandwidth-preserving server algorithms Each type of server is defined by a set of consumption and replenishment rules Three types of bandwidth-preserving servers deferrable servers sporadic servers constant utilization/total bandwidth servers and weighted fair-queueing servers © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems Deferrable Servers A deferrable server is the simplest bandwidth-preserving server Like a poller, the execution budget is replenished periodically Unlike a poller, when it finds no aperiodic job, it preserves its budget Operations of Deferrable Servers Consumption Rule The execution budget is consumed at the rate of one per unit time whenever the server executes Replenishment Rule The execution budget is set to at time instants for The server is not allowed to cumulate its budget from period to period Any budget held immediately before each replenishment time is lost (ex.) see Fig.7-3 The deferrable server algorithm is simple The scheduling overhead is no higher than that of a poller © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Deferrable Servers - continued 3 6 9 2 5.5 9 6.5 1.7 A 2.8 Budget 1.0 0.5 3 6 9 Fig. 7-3(a) Rate-monotonic schedule with a deferrable server © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Deferrable Servers - continued 3 6 9 2 5.5 9 6.5 1.7 A 2.8 Budget 1.0 0.5 3 6 9 Fig. 7-3(b) EDF schedule with a deferrable server © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Schedulability of Fixed-Priority Systems Lemma 7.1 In a fixed-priority system in which the relative deadline of every independent, preemptable periodic task is no greater than its period and there is a deferrable server with the highest priority among all tasks, a critical instant of every periodic task occurs at time when all the following are true One of its job is released at A job in every higher-priority task is released at the same time The budget of the server is at , one or more aperiodic jobs are released at , and they keep the server backlogged hereafter The next replenishment time of the server is The maximum (possible) amount of processor time consumed by the deferrable server in the feasible interval of is equal to © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Schedulability of Fixed-… - continued Time-Demand Analysis Method The time-demand function of the task is given by (Ref.) see Fig.7-6 (7.1) © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Schedulability of Fixed-… - continued 6 5 4 time demand functions 3 2 1 time 1 2 3 4 5 6 7 8 Fig. 7-6 The time-demand functions © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Schedulability of Deadline-Driven Systems Schedulable Utilization of the EDF Algorithm Let be the deadline of a job in some periodic task and be the latest time instant at which the processor is either idle or is executing a job whose deadline is after If does not complete by , then (7.3) (7.4) © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Schedulability of Deadline-… - continued Theorem 7.3 A periodic task in a system of n independent, preemptive periodic tasks is schedulable with a deferrable server according to the EDF algorithm if Proof) Try!! Try with (7.5) Fig. 7-7 The condition under which the deferrable server Consumes the most tine © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems Sporadic Servers Each sporadic server never demands more processor time than the periodic task in any time interval A deferrable server may delay lower-priority tasks for more time than a periodic task with the same period and execution time A system of periodic tasks containing a sporadic server may be schedulable while the same system containing a deferrable server with the same parameters is not Different kinds of sporadic servers differ in their consumption and replenishment rules More complicated rules allow a server to preserve its budget for a longer time, replenish the budget more aggressively, in a deadline-driven system, execute at a higher priority By using different rules, you can trade off the responsiveness of the server for the overhead in its implementation © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Sporadic Server in Fixed-Priority Systems Simple Sporadic Server Consumption Rules: At any time after , the server’s execution budget is consumed at the rate of 1 per unit time until the budget is exhausted when either one of the following two conditions is true. When these conditions are not true, the server holds its budget C1 The server is executing C2 The server has executed since and Replenishment Rules R1 Initially when the system begins execution and each time when the budget is replenished, the execution budget , and the current time R2 At time , if If The next replenishment time is set at R3 The next replenishment occurs at the next replenishment time, except under the following conditions. Under these conditions, replenishment is done at times stated below (a) If the next replenishment time is earlier than , the budget is replenished as soon as it is exhausted (b) If the system T becomes idle before the next replenishment time and becomes busy again at , budget is replenished at © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Sporadic Server in Fixed-… - continued 3 6 9 12 15 18 21 24 3 6 9 12 15 18 21 24 1.0 2.0 2.0 Budget 3 7 15.5 1.5 1.0 0.5 3 8 9.5 13 15 18 24 Fig. 7-8 Example illustrating the operations of a simple sporadic server: © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Schedulability of Sporadic Jobs Schedulability of Sporadic Jobs in Deadline-Driven Systems The density of a sporadic job that has release time , maximum execution time and deadline is the ratio A sporadic job is said to be active in its feasible interval ; it is not active outside of this interval Theorem 7.4 A system of independent, preemptable sporadic jobs is schedulable according to the EDF algorithm if the total density of all active in the system is no greater than 1 at all times Proof) Try!! © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Schedulability of Sporadic Jobs - continued Let denote the jth job of the sporadic task Let the period of denote the length of time between the release times of and The instantaneous utilization of is The instantaneous utilization of a sporadic task is such that Corollary 7.5 A system of n independent, preemptable sporadic tasks, which is such that the relative deadline of every job is equal to its period, is schedulable according to EDF if the total instantaneous utilization (i.e., ), is equal to or less than 1 Corollary 7.6 A system of independent, preemptable period and sporadic tasks, which is such that the relative deadline of every job is equal to its period, is schedulable according to EDF of the sum of the total utilization of the periodic tasks and the total instantaneous utilization of sporadic tasks is equal to or less than 1 © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Constant Utilization Server Algorithm The consumption rule of a constant utilization server, and that of a total bandwidth or weighted fair-queueing server is quite simple A server consumes its budget only when it executes Replenishment Rules R1 Initially, and R2 When an aperiodic job with execution time arrives at time to an empty aperiodic job queue (a) if do nothing (b) if and R3 At the deadline of the server (a) if the server is backlogged, set the server deadline to and (b) if the server is idle, do nothing A constant utilization server is always given enough budget to complete the job at the head of its queue each time its budget is replenished Its deadline is set so that its instantaneous utilization is equal to © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Constant Utilization Server … - continued 3 6 9 12 15 18 21 24 7 15 23.5 1.0 2.0 2.0 Budget 3 6.9 15.5 2 1 3 8 9.5 13 15 18 24 Fig. 7-13 Example illustrating the operations of constant utilization server: © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Total Bandwidth Server Algorithm The total bandwidth server algorithm improves the responsiveness of a constant utilization server by allowing the server to claim the background time not used by periodic tasks This is done by having the scheduler replenish the server budget as soon as the budget is exhausted if the server is backlogged at the time or as soon as the server becomes backlogged Replenishment Rules R1 Initially, and R2 When an aperiodic job with execution time arrives at time to an empty job queue, set to and R3 When the server completes the current aperiodic job, the job is removed from its queue (a) If the server is backlogged, the server deadline is set to and (b) If the server is idle, do nothing © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Total Bandwidth Server Algorithm - continued A total bandwidth server does not behave like a sporadic task with a constant instantaneous utilization In any case, the total bandwidth server will not cause a job to miss its deadline if the constant utilization server will not Corollary 7.7 When a system of independent, preemptable periodic tasks is scheduled with one or more total bandwidth and constant utilization servers on the EDF basis, every periodic task and every server meets its deadlines if the sum of the total density of periodic tasks and the total size of all servers is no greater than 1 © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Total Bandwidth Server Algorithm - continued Effects of nonpreemptivity : the maximum execution time of nonpreemptable portions of all periodic tasks and jobs executed by servers : the minimum of the relative deadlines of all periodic tasks and the effective execution times of jobs executed by all servers The effective execution time of a job is the ratio of the job execution time and the server size Corollary 7.8 When a system of periodic tasks is scheduled with one or more total bandwidth and constant utilization servers on the EDF basis, every periodic task and every server meets its deadlines of the sum of the total density of the periodic tasks and the total size of all servers is no greater than Corollary 7.9 If the sum of the total density of all periodic tasks and the total size of total bandwidth and constant utilization servers that are scheduled on the EDF basis is no greater than 1, the tardiness of every periodic task or server is no greater than © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Fairness and Starvation By a scheduling algorithm being fair within a time interval, we mean that the fraction time of processor time in the interval attained by each server that is backlogged throughout the interval is proportional to the server size The normalized service : A scheduler is fair in the interval if the normalized services attained by all servers that are backlogged during the interval differ by no more than the fairness threshold In the ideal case, FR is equal to zero, and Equivalently, An algorithm that infinitesmally fine-grain time slices among ready servers can achieve ideal fairness Hence, ideal fairness is not realizable in practice FR is a design parameter © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Fairness and Starvation - continued Elimination of Starvation It is well-known in the communication literature that the virtual clock algorithm (i.e., nonpreemptive total bandwidth server algorithm) is unfair This is true for the total bandwidth server algorithm (why?) The simple scheme presented below, as well as the weighted fair-queueing algorithm, eliminates starvation and improve fairness by keeping the deadlines of backlogged servers sufficiently close to the current time Starvation-Free Constant Utilization/Background Server Replenishment Rules R1-R3 Within any busy interval of the system, replenish the budget of each backlogged server following the rules of a constant utilization server R4 Whenever a busy interval of the system ends, replenish the budget of all backlogged servers © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Fairness and Starvation - continued 4 8 12 16 20 24 28 32 36 40 44 8 16 24 32 40 12 24 36 18 26 34 42 (a) Behavior of total bandwidth servers Fig. 7-14 Example illustrating starvation and fairness: © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Fairness and Starvation - continued 4 10 14 16 20 22 26 30 34 38 42 8 14 20 26 34 42 12 18 24 30 42 18 26 34 42 (b) Behavior of starvation-free constant utilization/background Fig. 7-14 Example illustrating starvation and fairness: © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Preemptive Weighted Fair-Queueing Algorithm The well-known Weighted Fair-Queueing (WFQ) algorithm It is also called the PGPS (packet-by-packet GPS) algorithm A nonpreemptive algorithm for scheduling packet transmissions in switched networks The preemptive version of WFQ for CPU scheduling It is designed to ensure fairness among multiple servers The algorithm closely resembles the total bandwidth server algorithm Both are greedy, that is work conserving The total bandwidth server algorithm is unfair, but the WFQ algorithm gives bounded fairness © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Preemptive Weighted Fair-… - continued Emulation of GPS Algorithm The replenishment rules of the WFQ algorithm are such that a WFQ server emulates a GPS ser of the same size The deadline of the WFQ server is the time at which a GPS server would complete the job at the head of the server queue In the GPS algorithm, the scheduler schedules backlogged servers on a weighted round-robin basis, with an infinitesmally small round length and the time per round given to each server is proportional to the server size (see Fig.7-14(c)) The budget of each WFQ server is replenished in the same manner as the corresponding total bandwidth server, except for the way the server deadline is computed (see Fig.7-14(d)) © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Preemptive Weighted Fair-… - continued 5 10 15 21.2 25.2 29.2 33.2 37.2 41.2 45.2 5 10 15 21.1 29.2 37.2 45.2 7.5 15 25.2 37.2 18 26 34 42 (c) Behavior of generalized processor sharing servers Fig. 7-14 Example illustrating starvation and fairness: © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Preemptive Weighted Fair-… - continued 5 10 15 20 25.2 29.2 33.2 37.2 41.2 45.2 5 10 15 20 29.2 37.2 45.2 7.5 15 25.2 37.2 18 26 34 42 (d) Behavior of weighted fair-queueing servers with real-time deadlines Fig. 7-14 Example illustrating starvation and fairness: © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Preemptive Weighted Fair-… - continued Virtual Time versus Real-Time If the scheduler were to replenish server budget in the manner illustrated in Fig.7-14(d), it would have to recompute the deadlines of all backlogged servers whenever some server changes from idle to backlogged and vice versa While this recomputation may be acceptable for CPU scheduling, it is not for scheduling packet transmissions (why?) This recomputation is not necessary if the scheduler gives virtual-time deadlines called finish numbers The finish number of a server gives the number of the round in which the server budget would be exhausted of the backlogged servers were scheduled according to the GPS algorithm What’s the finish number at time 18 in Fig.7-14? © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Preemptive Weighted Fair-… - continued Virtual Time versus Real-Time - continued FN 40 36 28.8 24 16 8 t 5 10 15 18 25.2 29.2 (e) Mapping from real-time to finish number (virtual time) Fig. 7-14 (continued) © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Preemptive Weighted Fair-… - continued Rules of Preemptive Weighted Fair-Queueing Algorithm The scheduling and budget consumption rules of a WFQ server are essentially the same as those of a total bandwidth server Scheduling Rule: A WFQ server is ready for execution when it has budget and a finish time. The scheduler assigns priorities to ready WFQ servers based on their finish numbers: the smaller the finish number, the higher the priority Consumption Rule: A WFQ server consumes its budget only when it executes In addition to these rules, the WFQ algorithm is defined by rules governing the update of the total size of the backlogged servers and the finish number and the replenishment of server budget (see the textbook!!) © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Scheduling of Sporadic Jobs The scheduler performs an acceptance test on each sporadic job upon its arrival We assume that acceptance tests are performed on sporadic jobs in the EDF order Once accepted, sporadic jobs are ordered among themselves in the EDF order In a deadline-driven system, they are scheduled with periodic jobs on the EDF basis In a fixed-priority system, they are executed by a bandwidth preserving server We say that an acceptance test is optimal if it accepts a sporadic job if and only if the sporadic job can be feasibly scheduled without causing periodic jobs or sporadic jobs in the system to miss their deadlines © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Acceptance Test in Deadline-Driven Systems Theorem 7.4 says that in a deadline-driven system where the total density of all the periodic tasks is , all the accepted sporadic jobs can meet their deadlines as long as the total density of all the active sporadic jobs is no greater than at all times Acceptance Test Procedure For the first sporadic job the scheduler accepts if its density is no greater than At time when the scheduler does an acceptance test on , there are active sporadic jobs in the system These deadlines partition the time interval from to the infinity into intervals: Let be the time interval containing the deadline of Based on Theorem 7.4, the scheduler accepts the job if for all (7.11) © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Acceptance Test in Deadline-… - continued 4 8 12 6 12 8 2 7 8 4 8 14 9 13 14 Fig. 7-21 An acceptance test on © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Acceptance Test in Deadline-… - continued 4 6 8 9.5 12 8 2 7 8 4 8 14 9 13 14 Fig. 7-21 An acceptance test on © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems
Acceptance Test in Fixed-Priority Systems One way to schedule sporadic jobs in a fixed-priority system is to use a sporadic server to execute them When the first sporadic job arrives, the scheduler accepts if the slack of the job is larger than or equal to 0 The slack for a new job is where is the execution time of the completed portion of the existing sporadic job The new job cannot be accepted if its slack is less than 0 The scheduler accepts if for every existing sporadic job with deadline equal to or later than © Cheol-Hoon Lee SSLab, CNU, 2015 Ch.7 Scheduling Aperiodic and Sporadic Jobs in Priority-Driven Systems