2 scheduling for real time systems roadmap for section 2
play

2. Scheduling for Real-Time Systems Roadmap for Section 2 Task - PowerPoint PPT Presentation

2. Scheduling for Real-Time Systems Roadmap for Section 2 Task Assignment and Scheduling Uni- vs. Multi-Processor Scheduling Algorithms Critical Sections and Priority Inversion HPI Embedded Systems 2 Programming Task Assignment and


  1. 2. Scheduling for Real-Time Systems

  2. Roadmap for Section 2 � Task Assignment and Scheduling � Uni- vs. Multi-Processor Scheduling Algorithms � Critical Sections and Priority Inversion HPI Embedded Systems 2 Programming

  3. Task Assignment and Scheduling � Objective: allocation and scheduling of tasks on processors to ensure that deadlines are met Problem statement: � Given a set of tasks, task precedence constraints, task characteristics, and deadlines, we are asked to devise a feasible allocation/schedule on a given computer � Task � consumes resources (cpu, memory, input data) � produces results � Precedence constraints: T i needs output from T j HPI Embedded Systems 3 Programming

  4. Task Dependency Graph � Characteristics: � Precedence-relation "<“ � Release time � Deadline (hard, soft) � Relative deadline: absolute deadline - release time HPI Embedded Systems 4 Programming

  5. Periodicity � Periodic: released periodically, every P i seconds � Period P i � Runs once every period (not exactly every P i sec) � Sporadic: not periodic, invoked irregularly � Upper bound on invocation rate � Aperiodic: sporadic but without bounded invocation rate � Example: � Sensor is read every 10 ms. � If value exceeds threshold, signal is send out � Sensor task is periodic; period p = 10ms � Task that sends the signal is sporadic � Maximum invocation rate for this sporadic task? HPI Embedded Systems 5 Programming

  6. Feasibility of a Schedule � Task assignment/schedule is feasible if all tasks start after their release times and complete before their deadlines � Schedule S: Set of processors x Time � Set of tasks � S(i,t) is the task scheduled to be running on processor i at time t � Offline scheduling: precomputed schedule � Online scheduling: tasks are scheduled at arrival � Must be fast � Static-priority algorithms: tasks' priorities do not change within a mode (Rate Monotonic Scheduling - RMS) � Dynamic-priority algorithms: priority changes with time (Earliest Deadline First - EDF) HPI Embedded Systems 6 Programming

  7. Preemptive vs. non-preemptive Scheduling � Preemptive: tasks can be interrupted by other tasks � More flexible � Critical task must be allowed to interrupt less critical ones � Non-preemptive: task runs until completion or blocking • S1: sub optimal; non-preemptive • S2: T2 misses deadline; non- preemptive • S3: preemptive; resource optimal • Overhead for preemption; bookkeeping • Preemption not always possible: disk write HPI Embedded Systems 7 Programming

  8. Uni-processor Scheduling � Traditional rate-monotonic scheduling (RMS) � Periodic, preemptable tasks � Deadlines equal task period � Set of n tasks is schedulable if total processor utilization is no greater than n(2 1/n -1) � Task priorities are static; inversely related to periods � Optimal static-priority uniprocessor algorithm � Some results for deadline ≠ period � Rate monotonic deferred server (DS) � Similar to RMS � Can handle both: periodic and sporadic tasks HPI Embedded Systems 8 Programming

  9. Uni-processor Scheduling (contd.) � Earliest deadline first (EDF): � Tasks are preemptible � Task with earliest deadline has highest priority � Optimal uni-processor algorithm � If a task set is not schedulable on a single processor by EDF, there is no other algorithm that can successfully schedule that task set � Precedence and exclusion conditions: � RMS & EDF assume independent preemptible tasks � Only processing requirements are taken into account; memory, I/O, other resource requirements negligible HPI Embedded Systems 9 Programming

  10. Uni-processor Scheduling (contd.) � Multiple task versions: � System has primary and alternative version of tasks � Vary in execution time and quality of output � Primary: full-fledged task; top quality output � Alternative: bare-bone; lower-quality (acceptable) output; take less much execution time � Schedule may pick alternative tasks during overload � IRIS tasks (increased reward with increased service): � Quality of output is monotonically nondecreasing function of execution time � Example: iterative algorithms for computation of π HPI Embedded Systems 10 Programming

  11. Multiprocessor Scheduling � Task assignment problem generally is NP-hard � Use heuristics HPI Embedded Systems 11 Programming

  12. Multiprocessor Scheduling � Utilization balancing algorithm: � Assigns tasks to processors one by one � Balanced utilization at end of each step � Preemptive tasks � Next-fit algorithm: � Works in conjunction with RMS uni-processor algorithm � Divides task set into classes � Processors are exclusively assigned to tasks � Preemptive tasks HPI Embedded Systems 12 Programming

  13. Multiprocessor Scheduling (contd.) � Bin-packing algorithm: � Assigns tasks to processors so, that utilization does not exceed given threshold � Threshold is set so that uni-processor algorithm is able to schedule assigned tasks � Preemptive tasks � Myopic offline scheduling algorithm: � Deals with non-preemptive tasks � Builds schedule using a search process � Focused addressing and bidding algorithm: � Tasks arrive at individual processors � If schedule not feasible: processor may offload some of its workload onto other processors � Other processors may voluntarily take over tasks HPI Embedded Systems 13 Programming

  14. Multiprocessor Scheduling (contd.) � Buddy strategy: � Three categories: underloaded, fully loaded, and overloaded processors � Overloaded processors ask underloaded ones to take over some load � Assignment with precedence constraints: � Takes precedence constraints into account � Trial-and-error process: assign communicating processes onto same processor HPI Embedded Systems 14 Programming

  15. Scheduling Problems � Critical Sections: � Source of anomalous behavior: priority inversion � Lower-priority tasks can block higher-priority tasks � Priority inheritance/priority ceiling protocols: finite upper bound to the period of priority inversion � Mode Changes: � Mission can have multiple phases � Different task sets � Different priorities/arrival rates � How to add/delete tasks of the task list � Fault-Tolerant Scheduling: � Schedule backups in the event of failure HPI Embedded Systems 15 Programming

  16. Rate Monotonic Scheduling (RMS) � Applicable when � � All tasks in a given task set are periodic � Tasks have relative deadlines that are identical to their periods, respectively � � � We use the following notation: � � I i - k-th period of T i starts at I i + (k-1)P i 
 phase of task T i � � n - number of tasks in a task set � � d i - relative deadline of T i � � e i - execution time for task T i � � D i - absolute deadline of T i � � P i - period for P i , when periodic � r i - release time of T i � � HPI Embedded Systems 16 Programming

  17. RMS Schedulability � There exists a sufficient condition for RMS- schedulability : � � For a processor utilization less than 
 � n(2 1/n -1), 
 all tasks will meet their deadlines under RMS 
 (let n be the number of tasks in the task set). � HPI Embedded Systems 17 Programming

  18. Discussion of RMS Schedulability � Assumption: phasings = 0 � � T 1 : highest priority; non-interrupted � � e 1 ≤ P 1 necessary and sufficient condition for schedulability � � T 2 : how much time remains in [0, P 2 ] for execution? � � In [0,t] T 1 has started ⎡ t/P 1 ⎤ iterations � � In addition, we need e 2 time for execution of T 2 � � We are looking for t ∈ [0,P 2 ] with t = ⎡ t/P 1 ⎤ e 1 + e 2 � � ⎡ t/P 1 ⎤ changes only at multiples of P 1 in amounts of e 1 � � Looking for k with: k P 1 ≥ ke 1 + e 2 and kP 1 ≤ P 2 � � -> this is the necessary and sufficient condition for 
 schedulability of T 2 � � analog for T 3 : we are looking for t ∈ [0,P 3 ] with 
 t = ⎡ t/P 1 ⎤ e 1 + ⎡ t/P 2 ⎤ e 2 + e 3 � � Again, need to check only at multiples of P 1 and P 2 � HPI Embedded Systems 18 Programming

  19. Example for RMS Schedula- bility HPI Embedded Systems 19 Programming

  20. Graphical Representation of RMS-Schedulability � W i (t): total amount of work carried by tasks T 1 , T 2 ,..., T i , initiated in interval [0,t]. � � W i (t) = ∑ i j=1 e j ⎡ t/P j ⎤ � � W i (t) is constant and changes only with release of new tasks at τ i � � T i is RMS-schedulable when min i ∈ τ i W i (t) ≤ t � HPI Embedded Systems 20 Programming

  21. Sporadic Tasks � Naive approach: reserve slots for sporadic Tasks 
 -> wasting of CPU resources � � Example: 2.5 out of 10 slots reserved � Deferred server: "virtual slots" for sporadic tasks Processor executes other tasks when no sporadic tasks pending Sporadic task has maximum priority and interrupts anything else � Deferred server utilization > 50% may lead to missed deadlines P s = 6 (DS); e s = 3; U s = 3/6 = 50% P 1 = 6 (T 1 ); DS back-to-back: no chance for T 1 HPI Embedded Systems 21 Programming

Recommend


More recommend