Embedded System Scheduling RealTime Systems from Dr Chalermek
Embedded System Scheduling
Real-Time Systems (from Dr. Chalermek Intanagonwiwat) Result in severe consequences if logical and timing correctness are not met ¢ Two types exist ¢ l Soft real-time • Tasks are performed as fast as possible • Late completion of jobs is undesirable but not fatal. • System performance degrades as more & more jobs miss deadlines • Example: • Online Databases
Real-Time Systems (cont. ) (from Dr. Chalermek Intanagonwiwat) l Hard real-time • Tasks have to be performed on time • Failure to meet deadlines is fatal • Example : • Flight Control System l Qualitative Definition
Hard and Soft Real Time Systems (Operational Definition) (from Dr. Chalermek Intanagonwiwat) ¢ Hard Real Time System l ¢ Soft Real Time System l ¢ Validation by provably correct procedures or extensive simulation that the system always meets the timings constraints Demonstration of jobs meeting some statistical constraints suffices. Example – Multimedia System l 25 frames per second on an average
Embedded & Real-Time Systems Execute tasks correctly and IN time. ¢ Systems with multiple tasks need scheduling ¢
Definitions Ready time r – task available ¢ Schedule ¢ Completed C ¢ Deadline D ¢ From C. W. Mercer
Ready time Clock ¢ External interrupt ¢ Software e. g. branch ¢
Terms Periodic – aperiodic ¢ Fixed – variable computation time ¢ Predictable – unpredictable ¢ Preemptible – non preemptible ¢ Task overall activity ¢ Jobs individual computation ¢
Terminologies ¢ (from J. A. Stankovic) Job Each unit of work that is scheduled and executed by the system Task l A set of related jobs l For example, a periodic task Ti consists of jobs J 1, J 2, J 3, … coming at every period Release time l Time instant at which a job becomes available for execution l It can be executed at any time at or after the release time Deadline l Time instant by which a job should be finished l Relative deadline: Maximum allowable response time l Absolute deadline = release time + relative deadline l ¢ ¢ ¢ 9 Real-time computing 2020 -10 -28
Terminologies ¢ Periodic task Ti l l l ¢ l Absolute deadline = release time + relative deadline Response time = finish time – release time Deadline miss if l l 10 Period Pi Worst case execution time Ci Relative deadline Di Job Jik l ¢ (from J. A. Stankovic) Finish time > absolute deadline Response time of Jik > Di Real-time computing 2020 -10 -28
Real-Time Workload (from Insup Lee) Job (unit of work) l a computation, a file read, a message transmission, etc ¢ Attributes l Resources required to make progress l Timing parameters Absolute deadline Released Execution time ¢ Relative deadline
Real-Time Task ¢ (from Insup Lee) Task : a sequence of similar jobs l Periodic task (p, e) • Its jobs repeat regularly • Period p = inter-release time (0 < p) • Execution time e = maximum execution time (0 < e < p) • Utilization U = e/p 0 5 10 15
Periodic-Aperiodic Tasks From C. W. Mercer
Aperiodic Non-predictable Task From C. W. Mercer
Preemptible&nonpreemptible Tasks From C. W. Mercer
Commonly use real-time scheduling Clock-driven ¢ Weighted round-robin ¢ Priority driven ¢
Scheduling Algorithms in RTOS (cont. ) (from Dr. Chalermek Intanagonwiwat) ¢ Clock Driven All parameters about jobs (execution time/deadline) known in advance. l Schedule can be computed offline or at some regular time instances. l Minimal runtime overhead. l Not suitable for many applications. l
Scheduling Algorithms in RTOS (cont. ) (from Dr. Chalermek Intanagonwiwat) ¢ Weighted Round Robin l l l Jobs scheduled in FIFO manner Time quantum given to jobs is proportional to it’s weight Example use : High speed switching network • QOS guarantee. l Not suitable for precedence constrained jobs. • Job A can run only after Job B. No point in giving time quantum to Job B before Job A.
Example task set From C. W. Mercer
First in First out (FIFO) From C. W. Mercer
Round Robin scheduling From C. W. Mercer
Cyclic executive From C. W. Mercer
Cyclic executive From C. W. Mercer
Cyclic executive modified From C. W. Mercer
Scheduling Algorithms in RTOS (cont. ) (from Dr. Chalermek Intanagonwiwat) ¢ Priority Scheduling Processor never left idle when there are ready tasks l Processor allocated to processes according to priorities l Priorities l • Static - at design time • Dynamic - at runtime
Priority Scheduling (from Dr. Chalermek Intanagonwiwat) ¢ Earliest Deadline First (EDF) l ¢ Least Slack Time First (LSF) l ¢ Process with earliest deadline given highest priority slack = relative deadline – execution left Rate Monotonic Scheduling (RMS) l l For periodic tasks Tasks priority inversely proportional to it’s period
Schedulability ¢ (4, 1) (5, 2) (7, 2) (from Insup Lee) Property indicating whether a real-time system (a set of real-time tasks) can meet their deadlines
Real-Time Scheduling (from Insup Lee) ¢ ¢ ¢ Determines the order of real-time task executions Static-priority scheduling Dynamic-priority scheduling (4, 1) (5, 2) (7, 2) 5 10 15
RM (Rate Monotonic) ¢ ¢ (from Insup Lee) Optimal static-priority scheduling It assigns priority according to period A task with a shorter period has a higher priority Executes a job with the shortest period T 1 (4, 1) T 2 (5, 2) T 3 (7, 2) 5 10 15
RM (Rate Monotonic) ¢ (from Insup Lee) Executes a job with the shortest period T 1 (4, 1) T 2 (5, 2) T 3 (7, 2) 5 10 15
RM (Rate Monotonic) ¢ (from Insup Lee) Executes a job with the shortest period Deadline Miss ! T 1 (4, 1) T 2 (5, 2) T 3 (7, 2) 5 10 15
Response Time ¢ (from Insup Lee) Response time l Duration from released time to finish time T 1 (4, 1) T 2 (5, 2) T 3 (10, 2) 5 10 15
Response Time ¢ (from Insup Lee) Response time l Duration from released time to finish time Response Time T 1 (4, 1) T 2 (5, 2) T 3 (10, 2) 5 10 15
Response Time (from Insup Lee) ¢ Response Time (ri) [Audsley et al. , 1993 ¢ HP(Ti) : a set of higher-priority tasks than Ti T 1 (4, 1) T 2 (5, 2) T 3 (10, 2) 5 10
RM - Schedulability Analysis (from Insup Lee) ¢ Real-time system is schedulable under RM if and only if ri ≤ pi for all task Ti(pi, ei) Joseph & Pandya, “Finding response times in a real-time system”, The Computer Journal, 1986.
RM – Utilization Bound (from Insup Lee) ¢ Real-time system is schedulable under RM if ∑Ui ≤ n (21/n-1) Liu & Layland, “Scheduling algorithms for multiprogramming in a hard-real-time environment”, Journal of ACM, 1973.
RM – Utilization Bound (from Insup Lee) ¢ Real-time system is schedulable under RM if ∑Ui ≤ n (21/n-1) ¢ Example: T 1(4, 1), T 2(5, 1), T 3(10, 1), ∑Ui = 1/4 + 1/5 + 1/10 = 0. 55 3 (21/3 -1) ≈ 0. 78
RM – Utilization Bound (from Insup Lee) ¢ Real-time system is schedulable under RM if ∑Ui ≤ n (21/n-1)
Rate monotonic schedulable bound From C. W. Mercer
EDF (Earliest Deadline First) (from Insup Lee) ¢ ¢ ¢ Optimal dynamic priority scheduling A task with a shorter deadline has a higher priority Executes a job with the earliest deadline T 1 (4, 1) T 2 (5, 2) T 3 (7, 2) 5 10 15
EDF (Earliest Deadline First) (from Insup Lee) ¢ Executes a job with the earliest deadline T 1 (4, 1) T 2 (5, 2) T 3 (7, 2) 5 10 15
EDF (Earliest Deadline First) (from Insup Lee) ¢ Executes a job with the earliest deadline T 1 (4, 1) T 2 (5, 2) T 3 (7, 2) 5 10 15
EDF (Earliest Deadline First) (from Insup Lee) ¢ Executes a job with the earliest deadline T 1 (4, 1) T 2 (5, 2) T 3 (7, 2) 5 10 15
EDF (Earliest Deadline First) (from Insup Lee) ¢ Optimal scheduling algorithm l if there is a schedule for a set of real-time tasks, EDF can schedule it. T 1 (4, 1) T 2 (5, 2) T 3 (7, 2) 5 10 15
Processor Demand Bound (from Insup Lee) ¢ Demand Bound Function : dbf(t) l the maximum processor demand by workload t over any interval of length t T 1 (4, 1) T 2 (5, 2) T 3 (7, 2) 5 10 15
EDF - Schedulability Analysis (from Insup Lee) ¢ Real-time system is schedulable under EDF if and only if dbf(t) ≤ t for all interval t Baruah et al. “Algorithms and complexity concerning the preemptive scheduling of periodic, real-time tasks on one processor”, Journal of Real-Time Systems, 1990. ¢ Demand Bound Function : dbf(t) l the maximum processor demand by workload over any interval of length t
EDF – Utilization Bound (from Insup Lee) ¢ Real-time system is schedulable under EDF if and only if ∑Ui ≤ 1 Liu & Layland, “Scheduling algorithms for multiprogramming in a hard-real-time environment”, Journal of ACM, 1973.
EDF – Overload Conditions (from Insup Lee) ¢ Domino effect during overload conditions Deadline Miss ! l Example: T 1(4, 3), T 2(5, 3), T 3(6, 3), T 4(7, 3) T 1 0 T 2 T 3 T 4 3 5 6 7 Better schedules : T 1 0 T 3 3 T 1 5 6 7 0 T 4 3 5 6 7
Least Slack Time First (LSF) l slack = relative deadline – execution left
- Slides: 49