3.A Fixed-Priority Scheduling
Total Page:16
File Type:pdf, Size:1020Kb
2017/18 UniPD - T. Vardanega 10/03/2018 Standard notation : Worst-case blocking time for the task (if applicable) 3.a Fixed-Priority Scheduling : Worst-case computation time (WCET) of the task () : Relative deadline of the task : The interference time of the task : Release jitter of the task : Number of tasks in the system Credits to A. Burns and A. Wellings : Priority assigned to the task (if applicable) : Worst-case response time of the task : Minimum time between task releases, or task period () : The utilization of each task ( ⁄) a-Z: The name of a task 2017/18 UniPD – T. Vardanega Real-Time Systems 168 of 515 The simplest workload model Fixed-priority scheduling (FPS) The application is assumed to consist of tasks, for fixed At present, the most widely used approach in industry All tasks are periodic with known periods Each task has a fixed (static) priority determined off-line This defines the periodic workload model In real-time systems, the “priority” of a task is solely derived The tasks are completely independent of each other from its temporal requirements No contention for logical resources; no precedence constraints The task’s relative importance to the correct functioning of All tasks have a deadline equal to their period the system or its integrity is not a driving factor at this level A recent strand of research addresses mixed-criticality systems, with Each task must complete before it is next released scheduling solutions that contemplate criticality attributes All tasks have a single fixed WCET, which can be trusted as The ready tasks (jobs) are dispatched to execution in a safe and tight upper-bound the order determined by their (static) priority Operation modes are not considered Hence, in FPS, scheduling at run time is fully defined by the All system overheads (context-switch times, interrupt handling and so on) are assumed absorbed in the WCETs priority assignment algorithm 2017/18 UniPD – T. Vardanega Real-Time Systems 167 of 515 2017/18 UniPD – T. Vardanega Real-Time Systems 169 of 515 Real Time Systems 1 2017/18 UniPD - T. Vardanega 10/03/2018 Preemption and non-preemption /1 Rate-monotonic priority assignment With priority-based scheduling, a high-priority task may be Each task is assigned a priority based on its period released during the execution of a lower priority one The shorter the period, the higher the priority In a preemptive scheme, there will be an immediate switch to Such priorities have to be unique: hence ties must be resolved the higher-priority task For any two tasks , : → With non-preemption, the lower-priority task will be allowed Rate monotonic assignment is optimal under preemptive to complete before the other may execute priority-based scheduling (and implicit deadlines) Preemptive schemes (such as FPS and EDF) enable higher- Nomenclature priority tasks to be more reactive, hence they are preferred Priority 1 as numerical value is the lowest (least) priority, but the indices are still sorted highest to lowest (!) 2017/18 UniPD – T. Vardanega Real-Time Systems 170 of 515 2017/18 UniPD – T. Vardanega Real-Time Systems 172 of 515 Preemption and non-preemption /2 Utilization-based test Alternative strategies allow a lower priority task to continue A simple test exists for rate-monotonic scheduling executing for a bounded time before being preempted It provides a sufficient but not necessary upper-bound Such schemes use either deferred preemption or cooperative on the schedulable utilization of FPS dispatching Only for task sets with Value-based scheduling (VBS) is another approach to attenuating preemption Useful when the system becomes overloaded and some adaptive 2 1 scheme of scheduling is needed to mitigate the risk or the consequences of overrun VBS assigns a value to each task and then employs an on-line value- based scheduling algorithm to decide which task to run next lim 2 1 ln20.69 Analogous to usefulness, but determined off-line → 2017/18 UniPD – T. Vardanega Real-Time Systems 171 of 515 2017/18 UniPD – T. Vardanega Real-Time Systems 173 of 515 Real Time Systems 2 2017/18 UniPD - T. Vardanega 10/03/2018 Critique of utilization-based tests Timeline for task set A Task These tests are sufficient but not necessary Task Release Time As such, they fall in the class of schedulability tests a Task Completion Time These tests are not exact and also not general Deadline Met b Task Completion Time But they are Ω , which makes them interesting Deadline Missed for some users c Preempted Time Executing 0102030405060 2017/18 UniPD – T. Vardanega Real-Time Systems 174 of 515 2017/18 UniPD – T. Vardanega Real-Time Systems 176 of 515 Example: task set A Example: task set B Task Period Computation Time Priority Utilization Task Period Computation Time Priority Utilization TC PU TC PU a5012 1 (low)0.24 a8032 1 (low)0.40 b 40 10 2 0.25 b 40 5 2 0.125 c 30 10 3 (high) 0.33 c 16 4 3 (high) 0.25 The combined utilization is 0.82 (or 82%) The combined utilization is 0.775 Above the threshold for three tasks (0.78) Below the threshold for three tasks (0.78) This task set fails the utilization test This task set passes the utilization test Hence we have no a-priori answer on its feasibility Hence this task set will meet all its deadlines 2017/18 UniPD – T. Vardanega Real-Time Systems 175 of 515 2017/18 UniPD – T. Vardanega Real-Time Systems 177 of 515 Real Time Systems 3 2017/18 UniPD - T. Vardanega 10/03/2018 Example: task set C Response time analysis /1 Task Period Computation Time Priority Utilization The worst-case response time of task is first TC PU calculated and then checked (trivially) with its a8040 1 (low)0.50 deadline b 40 10 2 0.25 is feasible iff c 20 5 3 (high) 0.25 , where is the interference that The combined utilization is 1.0 suffers from higher-priority tasks Above the threshold for three tasks (0.78) Again, this task set does not pass the utilization test Yet the timeline shows the task set will meet all its deadlines 2017/18 UniPD – T. Vardanega Real-Time Systems 178 of 515 2017/18 UniPD – T. Vardanega Real-Time Systems 180 of 515 Timeline for task set C Calculating R Task Within , each higher priority task will execute at a most times The ceiling function gives the smallest integer greater than b the fractional number on which it acts E.g., the ceiling of 1/3 is 1, of 6/5 is 2, and of 6/3 is 2 Using the ceiling reflects the fact that will be preempted for c a full execution of a higher-priority released exactly at ’s end The total interference suffered by from in Time 20 30 40 50 60 70 80 where , is given by 010 2017/18 UniPD – T. Vardanega Real-Time Systems 179 of 515 2017/18 UniPD – T. Vardanega Real-Time Systems 181 of 515 Real Time Systems 4 2017/18 UniPD - T. Vardanega 10/03/2018 Response time equation Example: task set D Task Period Computation Time Priority Utilization TC P U a 7 3 3 (high) 0.4285… b123 2 0.25 Where is the set of tasks with priority higher than c205 1 (low)0.25 Solved by forming a recurrence relationship The set of values is monotonically non-decreasing When the solution to the equation has been found must not be greater than (e.g. 0 or ) 2017/18 UniPD – T. Vardanega Real-Time Systems 182 of 515 2017/18 UniPD – T. Vardanega Real-Time Systems 184 of 515 Response time algorithm Example (cont’d) for i in 1..N loop -- for each task in turn n := 0 If the recurrence does not converge loop before Ti we can still set a termination calculate new condition that attempts to determine if then how long past Ti job i completes exit value found end if if then exit value not found end if n := n + 1 end loop end loop 2017/18 UniPD – T. Vardanega Real-Time Systems 183 of 515 2017/18 UniPD – T. Vardanega Real-Time Systems 185 of 515 Real Time Systems 5 2017/18 UniPD - T. Vardanega 10/03/2018 Revisiting task set C Sporadic tasks Task Period Computation Time Priority Response Time Sporadic tasks have a minimum inter-arrival time TC PR Which should be preserved at run time if schedulability is a80401 (low)80 to be ensured, but how can it ? b4010 2 15 They also require D c205 3 (high)5 The RTA for FPS works perfectly for D<T as long as the stopping criterion becomes The combined utilization is 1.0, above the utilization threshold for three tasks (0.78) Hence the utilization test fails But RTA shows that the task set will meet all its deadlines Interestingly this also works perfectly well with any Cf. the impasse we had at pages 178-179 priority ordering as long as the indices reflect it 2017/18 UniPD – T. Vardanega Real-Time Systems 186 of 515 2017/18 UniPD – T. Vardanega Real-Time Systems 188 of 515 Response time analysis /2 Hard and soft tasks RTA is a feasibility test In many situations the WCET given for sporadic Exact, hence necessary and sufficient tasks are considerably higher than the average case If the task set passes the test then all its tasks will Interrupts often arrive in bursts and an abnormal meet all their deadlines sensor reading may lead to significant additional If it fails the test then, at run time, some tasks will computation miss their deadline and FPS tells us exactly which Measuring feasibility with WCET may lead to very Unless the computation time estimations (the WCET) themselves turn out to be pessimistic low processor utilization being observed at run time We need some common sense to contain pessimism 2017/18 UniPD – T.