Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi
CS3204 Fall /3/06 2 Real-Time Systems Systems that must service requests within a precise time constraint: Air traffic control systems Railway switching systems Industrial automation Robotics Military Generally, systems that must respond to external physical phenomena.
CS3204 Fall /3/06 3 Tracking System Example Dynamic trajectory calculations False alarms Verification System response Real-time clock 687m error!
CS3204 Fall /3/06 4 System Resources Different approaches to resource management: General-purpose OS Extensible time horizon: all tasks eventually finish Similarly, elastic memory: demand paging Fairness Non-starvation Real-Time system Fixed resources Tasks adjusted accordingly Predictability
CS3204 Fall /3/06 5 Schedulers Preemptive / non-preemptive Static / dynamic On-line / off-line Optimal / heuristic Clairvoyance
CS3204 Fall /3/06 6 Real-Time Task Parameters CiCi aiai didi sisi fifi t Arrival time Computation time start time finish time deadline
CS3204 Fall /3/06 7 Real-Time Tasks CiCi aiai didi sisi fifi t CiCi aiai didi sisi fifi t Laxity (slack) Deadline miss x
CS3204 Fall /3/06 8 RMA Rate Monotonic Algorithm Static Preemptive Fixed-priority assignment Periodic tasks Guarantee-based Hard real-time correctness – all deadlines always met
CS3204 Fall /3/06 9 RMA (continued) RMA: Assign unique priorities, in descending order, to tasks ordered by ascending periods: the shorter the period, the higher the priority.
CS3204 Fall /3/06 10 RMA – Example TaskTCP A51 B C A Assume deadline equals period (T).
CS3204 Fall /3/06 11 RMA – Example TaskTCP A51 B93 C A B
CS3204 Fall /3/06 12 RMA – Example TaskTCP A51 B93 C122 A B C
CS3204 Fall /3/06 13 RMA – Example TaskTCP A513 B932 C1221 A B C
CS3204 Fall /3/06 14 RMA – Example TaskTCP A513 B932 C1221 A B C
CS3204 Fall /3/06 15 RMA – Example TaskTCP A513 B932 C1221 A B C
CS3204 Fall /3/06 16 RMA – Example TaskTCP A513 B932 C1221 A B C
CS3204 Fall /3/06 17 RMA – Example TaskTCP A513 B932 C1221 A B C A preempts C
CS3204 Fall /3/06 18 RMA – Example TaskTCP A513 B932 C1221 A B C
CS3204 Fall /3/06 19 RMA – Example TaskTCP A513 B932 C1221 A B C
CS3204 Fall /3/06 20 RMA – Example TaskTCP A513 B932 C1221 A B C A preempts B
CS3204 Fall /3/06 21 RMA – Example TaskTCP A513 B932 C1221 A B C C arrives
CS3204 Fall /3/06 22 RMA – Example TaskTCP A513 B932 C1221 A B C
CS3204 Fall /3/06 23 RMA – Example TaskTCP A513 B932 C1221 A B C
CS3204 Fall /3/06 24 RMA – Example TaskTCP A513 B932 C1221 A B C
CS3204 Fall /3/06 25 RMA (continued) How far can we push this? Constraints Number of tasks? Periods? Computational times?
CS3204 Fall /3/06 26 Processor Utilization Factor Fraction of CPU time spent in execution of tasks: Otherwise stated: sum of the individual relative load contribution of each task in the task-set. Provides an indication of system-wide computational load.
CS3204 Fall /3/06 27 Feasibility Test RMA guarantee: No deadlines will be missed under rate monotonic scheduling if the following condition holds:
CS3204 Fall /3/06 28 Feasibility Test (continued) Note that: That is, any task-set with a CPU utilization factor of 69% or less is schedulable under RMA Sufficient, but not necessary condition
CS3204 Fall /3/06 29 Optimality RMA is an optimal fixed-priority assignment algorithm: no other fixed- priority algorithms can schedule a task set that cannot be scheduled under RMA.
CS3204 Fall /3/06 30 EDF Earliest Deadline First Earlier the deadline, higher the priority. Dynamic assignment On-line No periodicity assumptions – can schedule aperiodic tasks.
CS3204 Fall /3/06 31 EDF – Example TaskTC A41 B84 C Assume deadline equals period (T). A B C Hyper-period
CS3204 Fall /3/06 32 EDF – Example TaskTC A41 B84 C Assume deadline equals period (T). A B C
CS3204 Fall /3/06 33 EDF – Example TaskTC A41 B84 C Assume deadline equals period (T). A B C
CS3204 Fall /3/06 34 EDF – Example TaskTC A41 B84 C Assume deadline equals period (T). A B C Lexical order tie breaker
CS3204 Fall /3/06 35 EDF – Example TaskTC A41 B84 C Assume deadline equals period (T). A B C
CS3204 Fall /3/06 36 EDF – Example TaskTC A41 B84 C Assume deadline equals period (T). A B C
CS3204 Fall /3/06 37 EDF – Example TaskTC A41 B84 C Assume deadline equals period (T). A B C
CS3204 Fall /3/06 38 EDF – Example TaskTC A41 B84 C Assume deadline equals period (T). A B C Pattern repeats
CS3204 Fall /3/06 39 EDF Properties Feasibility test: U = 100% in example Bound theoretical Sufficient and necessary Optimal
CS3204 Fall /3/06 40 Overload Hard real-time No deadlines misses. Dimension system to meet exact timing requirements. Soft real-time May encounter transient or sustained overload. Design algorithm to achieve desired temporal behavior.
CS3204 Fall /3/06 41 Real-Time Overload Scheduling Runtime uncertainty Dynamic system Aggregate demand exceeds capacity Fixed available bandwidth Must shed load Starvation Who survives?
CS3204 Fall /3/06 42 EDF Domino Effect Deadline sole scheduling parameter
CS3204 Fall /3/06 43 EDF Domino Effect X X X Cascading deadline misses Deadline sole scheduling parameter
CS3204 Fall /3/06 44 Load Shedding Feasible schedule if any task excluded in example? Selection criteria Fitness metric Second dimension: utility
CS3204 Fall /3/06 45 Load Shedding X X X Overload detected
CS3204 Fall /3/06 46 Load Shedding X X X Least valuable task u = 3 u = 1 u = 5 u = 7 Two scheduling parameters: deadline and utility
CS3204 Fall /3/06 47 Load Shedding X Least valuable task u = 3 u = 1 u = 5 u = 7