Real-Time Scheduling Single Processor Chenyang Lu
Critiques Ø 1/2 page critiques of research papers. q Back-of-envelop comments - NOT whole essays. q Guidelines: http://www.cs.wustl.edu/%7Elu/cse521s/critique.html Ø Critique #1 q Email to Jiangnan by 10am, 2/18 - hard deadline ! q The Design and Performance of a Real-time CORBA Event Service 2
Readings Ø Single-Processor Scheduling q Hard Real-Time Computing Systems, by G. Buttazzo. • Chapter 4 Periodic Task Scheduling • Chapter 5 (5.1-5.4) Fixed Priority Servers • Chapter 7 (7.1-7.3) Resource Access Protocols Ø Further references q A Practitioner's Handbook for Real-Time Analysis: Guide to Rate Monotonic Analysis for Real-Time Systems, by Klein et al. q Deadline Scheduling for Real-Time Systems: EDF and Related Algorithms, by Stankovic et al.
Real-Time Scheduling Ø What are the optimal scheduling algorithms? Ø How to assign priorities to tasks? Ø Can a system meet all deadlines?
Benefit of Scheduling Analysis •Schedulability analysis reduces development time by 50%! •Reduce wasted implementation/testing rounds •Analysis time << testing •Quick exploration of design space! •More reduction expected for more complex systems VEST (UVA) Baseline (Boeing) Design – one processor 40 Design – one processor 25 Implementation – one processor 75 Scheduling analysis - MUF ´ 1 Timing test ´ 30 Design - two processors 25 Design - two processors 90 Implementation – two processors 105 Scheduling analysis - DM/Offset Ö 1 Timing test Ö 20 “Implementation” 105 Total composition time 172 Total composition time 345 J.A. Stankovic, et al., VEST: An Aspect-Based Composition Tool for Real-Time Systems, RTAS 2003.
Consequence of Deadline Miss Ø Hard deadline q System fails if missed. q Goal: guarantee no deadline miss. Ø Soft deadline q User may notice, but system does not fail. q Goal: meet most deadlines most of the time.
Cyber-Physical Systems (CPS) Cyber-Physical Boundary Real-Time Hybrid Simulation (RTHS) Ø Since the application interacts with the physical world, its computation must be completed under a time constraint. Ø CPS are built from, and depend upon, the seamless integration of computational algorithms and physical components. [NSF] 7 ^ Robert L. and Terry L. Bowen Large Scale Structures Laboratory at Purdue University
Cyber-Physical Systems (CPS) Cyber-Physical Boundary 8
Interactive Cloud Services (ICS) Need to respond within100ms for users to find responsive*. Query doc Doc. index search 2 nd phase ranking Snippet generator Response Search the web 9 * Jeff Dean et al. (Google) "The tail at scale." Communications of the ACM 56.2 (2013)
Interactive Cloud Services (ICS) Need to respond within100ms for users to find responsive*. E.g., web search, online gaming, stock trading etc. Search the web 10 * Jeff Dean et al. (Google) "The tail at scale." Communications of the ACM 56.2 (2013)
Comparison Ø General-purpose systems q Fairness to all tasks (no starvation) q Optimize throughput q Optimize average performance Ø Real-time systems q Meet all deadlines. q Fairness or throughput is not important q Hard real-time: worry about worst case performance Chenyang Lu 11
Terminology Ø Task q Map to a process or thread q May be released multiple times Ø Job: an instance of a task Ø Periodic task q Ideal: inter-arrival time = period q General: inter-arrival time >= period Ø Aperiodic task q Inter-arrival time does not have a lower bound Chenyang Lu 12
Timing Parameters Ø Task T i q Period P i q Worst-case execution time C i q Relative deadline D i Ø Job J ik q Release time: time when a job is ready q Response time R i = finish time – release time q Absolute deadline = release time + D i Ø A job misses its deadline if q Response time R i > D i q Finish time > absolute deadline Chenyang Lu 13
Example Ø P 1 = D 1 = 5, C 1 = 2; P 2 = D 2 = 7, C 2 = 4. Chenyang Lu 14
Metrics Ø A task set is schedulable if all jobs meet their deadlines. Ø Optimal scheduling algorithm q A task set is unschedulable under the optimal algorithm à unschedulable under any other algorithms. Ø Overhead: Time required for scheduling. Chenyang Lu 15
Optimal Scheduling Algorithms Ø Rate Monotonic (RM) q Higher rate (1/period) à Higher priority q Optimal preemptive static priority scheduling algorithm Ø Earliest Deadline First (EDF) q Earlier absolute deadline à Higher priority q Optimal preemptive dynamic priority scheduling algorithm Chenyang Lu 16
Example Ø P 1 = D 1 = 5, C 1 = 2; P 2 = D 2 = 7, C 2 = 4. Chenyang Lu 17
Assumptions Ø Single processor. Ø All tasks are periodic. Ø Zero context switch time. Ø Relative deadline = period. Ø No priority inversion. Ø Have been extended to remove these assumptions. Chenyang Lu 18
Schedulable Utilization Bound • Utilization of a processor: n C = å i U P = i 1 i – n: number of tasks on the processor. • Utilization bound U b : All tasks are guaranteed to be schedulable if U ≤ U b . • No scheduling algorithm can schedule a task set if U>1 – U b ≤ 1 – An algorithm is optimal if its U b = 1 Chenyang Lu 19
RM Utilization Bound Ø U b (n) = n(2 1/n -1) q n: number of tasks q U b (2) = 0.828 q U b (n) ≥ U b ( ¥ ) = ln2 = 0.693 Ø U ≤ U b (n) is a sufficient condition, but not necessary. Ø U b = 1 if all task periods are harmonic q Periods are multiples of each other q e.g., 1,10,100 Chenyang Lu 20
Properties of RM Ø May not guarantee schedulability when CPU is not fully utilized. Ø Low overhead q When the task set is fixed, the priority of a task never changes. Ø Easy to implement on POSIX APIs. Chenyang Lu 21
EDF Utilization Bound Ø U b = 1 Ø U ≤ 1: sufficient and necessary condition for schedulability. Ø Guarantees schedulability if CPU is not over-utilized. Ø Higher overhead than RM: task priority may change online. Chenyang Lu 22
Assumptions Ø Single processor. Ø All tasks are periodic. Ø Zero context switch time. Ø Relative deadline = period. Ø No priority inversion. Ø What if relative deadline < period? Chenyang Lu 23
Optimal Scheduling Algorithms Relative Deadline < Period Ø Deadline Monotonic (DM) q Shorter relative deadline à Higher priority q Optimal preemptive static priority scheduling Ø Earliest Deadline First (EDF) q Earlier absolute deadline à Higher priority q Optimal preemptive dynamic priority scheduling algorithm Chenyang Lu 24
DM Analysis • Sufficient but pessimistic test n C å £ 1/ n i n (2 -1) D = i 1 i • Sufficient and necessary test: response time analysis Chenyang Lu 25
Response Time Analysis • Works for any fixed-priority preemptive scheduling algorithm. • Critical instant – results in a task’s longest response time. – when all higher-priority tasks are released at the same time. • Worst-case response time – Tasks are ordered by priority; T 1 has highest priority é ù - i 1 R å = + i R C ê ú C i i j P ê ú ê ú = j 1 j Chenyang Lu 26
Response Time Analysis Tasks are ordered by priority; T 1 has the highest priority. for (each task T j ) { I = 0; R = 0; while (I + C j > R) { R = I + C j ; if (R > D j ) return UNSCHEDULABLE; é ù R å j-1 I = C ; ê ú k k=1 P ê ú k } } return SCHEDULABLE; Chenyang Lu 27
Example Ø P 1 = D 1 = 5, C 1 = 2; P 2 = D 2 = 7, C 2 = 4. Chenyang Lu 28
EDF: Processor Demand Analysis • To start, assume D i = P i • Processor demand in interval [0, L]: total time needed for completing all jobs with deadlines no later than L. ê ú n L å = C ( 0 , L ) C ê ú P i P ë û = i 1 i Chenyang Lu 29
Schedulable Condition • A set of periodic tasks is schedulable by EDF if and only if for all L ³ 0: ê ú n L å ³ L C ê ú i P ë û = i 1 i • There is enough time to meet processor demand at every time instant. Chenyang Lu 30
Busy Period B p • End at the first time instant L when all the released jobs are completed • W(L): Total execution time of all tasks released by L. é ù n L = å W ( L ) C ê ú i P ê ú = i 1 i = = B min{ L | W ( L ) L } p Chenyang Lu 31
Properties of Busy Period • CPU is fully utilized during a busy period. • The end of a busy period coincides with the beginning of an idle time or the release of a periodic job. Chenyang Lu 32
Schedulable Condition • All tasks are schedulable if and only if ê ú n L å ³ L C ê ú i P ë û = i 1 i at all job release times before min(B p , H) Chenyang Lu 33
Compute Busy Period busy_period { H = lcm(P 1 ,…,P n ); /* least common multiple */ L = å C i ; L' = W(L); while (L' != L and L' <= H) { L = L'; L' = W(L); } if (L' <= H) B p = L; else B p = INFINITY; } Chenyang Lu 34
Processor Demand Test: D i < P i • A set of periodic tasks with deadlines no more than periods is schedulable by EDF if and only if é ù æ ö ê ú - n L D å " Î ³ + L D , L ê i 1 C ú ç ÷ ê ú ç ÷ i P ê ë û ú è ø ë û = i 1 i where D = {D i,k | D i,k = kP i +D i , D i,k £ min(B p , H), 1 £ i £ n, k ³ 0}. • Note: only need to test all deadlines before min(B p ,H). Chenyang Lu 35
Recommend
More recommend