1 / 16

Lecture 6: Real-Time Scheduling

Lecture 6: Real-Time Scheduling. Advanced Operating System Fall 2012. Real-Time Scheduling. A real-time task is defined to be one in which there is a hard deadline to meet; failure to meet the deadline can lead to disaster.

eudora
Télécharger la présentation

Lecture 6: Real-Time Scheduling

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 6: Real-Time Scheduling Advanced Operating System Fall 2012

  2. Real-Time Scheduling • A real-time task is defined to be one in which there is a hard deadline to meet; failure to meet the deadline can lead to disaster. • Example of real-time task include process control such as a nuclear reactor, automatic flight control, etc. • Real-time tasks can be classified as periodic or aperiodic. • Periodic: the processes are considered to be periodic if they require CPU at constant intervals (periods). • Each periodic process has a fixed processing time ei once it acquires the CPU, a deadline di when it must be serviced by the CPU, and a period pi. • The relationship of the processing time, the deadline and the period can be expressed as 0≤ei ≤di ≤pi. • The rate of a periodic task is 1/pi. • Aperiodic tasks are tasks that come in at random times. However, when it makes a request, it is guaranteed that it will not make a request until some time p later.

  3. Real-Time CPU Scheduling • Periodic: the processes are considered to be periodic if they require CPU at constant intervals (periods). • Each periodic process has a fixed processing time ei once it acquires the CPU, a deadline di when it must be serviced by the CPU, and a period pi. • The relationship of the processing time, the deadline and the period can be expressed as 0≤ei ≤di ≤pi. • The rate of a periodic task is 1/pi.

  4. Aperiodic tasks • Aperiodic tasks are tasks that come in at random times. However, when it makes a request, it is guaranteed that it will not make a request until some time p later.

  5. Rate-Monotonic Scheduling • The rate-monotonic scheduling algorithm schedules periodic tasks using a static priority policy with preemption. • If a lower-priority process is running and a higher-priority process becomes available to run, it will preempt the lower-priority process. • For each process, its priority=1/pi(inverse of the period). • The rationale behind this policy is to assign a higher priority to tasks that require the CPU more often. • Assumption: the processing time of a periodic process is the same for each CPU burst. • Severe constraints: processes must be periodic, independent and have deadline equal to period. All processes have an initial release at time 0.

  6. 2.2 2.5 11.2 3.0 4.0 4.3 5.0 6.0 7.2 8.0 8.3 9.0 12 7.0 1 10 0 T1 T2 T3 /// T1 T3 /// T2 T1 T2 /// T3 /// T1 T2 /// … Rate-Monotonic Scheduling: example Si: initial start time di: relative deadline pi: period i ei: maximum execution time Priority: T1: 1/3; T2: ¼; T3: ¼; T1: 0, 3, 6, 9, 12, … T2: 1, 5, 9, 13, … T3: 0, 4, 8, 12, …

  7. Rate-Monotonic Scheduling • Rate-Monotonic scheduling algorithm is considered optimal in the sense that if a set of processes cannot be scheduled by this algorithm, it cannot be scheduled by any other algorithm that assigns static priorities. • Despite being optimal, then rate-monotonic scheduling has a limitation: CPU utilization is bounded, and it is not always possible to fully maximize CPU resources. The worst-case CPU utilization for scheduling N processes is • As the number of processes approaches infinity, CPU utilization falls approximately 69%. • Feasibility test: • Two processes: CPU utilization is bounded about 83%. • Sufficient condition: If there are two processes to be scheduled and the combined CPU utilization is less than 83%, then the Rate-Monotonic scheduling algorithm is guaranteed to schedule them so that they can meet their deadline. Otherwise, it is inclusive. • The above condition is not necessary condition: Example Task 1: Execution time: 2, Period: 4; Task 2: Execution time: 4, Period: 8. Can be scheduled by DM scheduling algorithm, CPU utilization is 100%.

  8. Earliest-Deadline-First Scheduling (EDF) • Earliest-Deadline-First scheduling dynamically assigns priorities according to deadline. The earliest the deadline, the higher the priority. • Algorithm: At each moment of time t, schedule the task whose deadline is closest to t. Ties can be resolved arbitrarily. • EDF scheduling does not require that processes be periodic, nor must a process require a constant amount of CPU time per burst. • The only requirement is that a process announce its deadline to the scheduler when it becomes runnable. • EDF scheduling is theoretically optimal – theoretically, it can schedule processes so that each process can meet its deadline requirements and CPU utilization will be 100 percent. In practice, however, it is impossible to achieve this level of CPU utilization due to the cost of context switching between processes and interrupt handling.

  9. 2.2 2.5 11.2 3.0 4.0 4.3 5.0 6.0 7.2 8.0 8.3 9.0 12 7.0 1 10 0 T1 T2 T3 /// T1 T3 /// T2 T1 T2 /// T3 /// T1 T2 /// … Earliest-Deadline-First Scheduling (EDF): Example T1 makes a request at some unpredictable time. But if it makes a request at time t, then it is guaranteed that it will not make a request again at time t+3. The current request is expected to complete at time t+2, and it will take 1 time unit to finish. T1: 0, 3, 6, 9, 12, … T2: 1, 5, 9, 13, … T3: 0, 4, 8, 12, …

  10. Example: Rate-monotonic scheduling: misses deadlines Earliest-Deadline-First scheduling:

  11. Feasibility Test for EDF alg.: • Feasibility Test: • Necessary condition: is a necessary (but not sufficient condition) for a feasible schedule. Example: Since we can have feasible schedule for the above example, this condition holds. • Sufficient condition: is a sufficient (but not necessary condition) for a feasible schedule. Example: Since in the above example, we have: ½+1.2/3+ 0.3/4=0.5+0.4+0.075=0.975, sufficient condition holds, so we are sure that there exists feasible schedule. • If it satisfies necessary condition, but fails sufficient condition, we cannot be sure. However, there is a procedure to determine. Too complicated to explain.

  12. Feasibility Test for EDF alg.: • We can always test the feasibility by constructing a schedule using EDF algorithm from 0 until some time T and check if all deadlines within [0, T] are met and certain condition satisfied. • Two cases: • Suppose si=sj=0 for any i and j, run EDF alg from 0 to T=LCM{p1, p2, …, pn}, if all deadlines are met, then feasible; otherwise, not feasible. • Suppose si≠sj for any i and j, construct a schedule from time 0 until time t2=S+2T, where S=max{s1, s2, …, sn}, and T=LCM{p1,p2,…, pn}, if all deadlines in [0, t2] are met, then feasible; otherwise, not feasible.

  13. Deadline-Monotonic Algorithm (DM) • Working for both periodic tasks and Aperiodic tasks. • Fixed-priority • Uses relative deadlines: the shorter the relative deadline, the higher the priority • RM and DM are identical if the relative deadline is proportional to its period • Otherwise DM performs better in the sense that it can sometimes produce a feasible schedule when RM fails, while RM always fails when DM fails • Feasibility Test: • T = {T1, T2, ..., Tn}, ordered by priority (i < j, i < j) • Sufficient condition: for any i: 1≤i ≤n,

  14. DM example • t1 : e1 = 2, d1 = 3, p1 = 5 • t2 : e2 = 2, d2 = 6, p2 = 15 • t3 : e3 = 4, d3 = 10, p3 = 20

  15. Reference • Leung, J. Y-T. and J. Whitehead, "On the Complexity of Fixed-Priority Scheduling of Periodic, Real-Time Tasks," Performance Evaluation, 2:237-250, 1982. Also in Proc. of the 18th Annual Allerton Conference on Communication, Control, and Computing, 464-470, Urbana-Champaign, IL, 1980. • Leung, J. Y-T. and M. L. Merrill, "A Note on Preemptive Scheduling of Periodic, Real-Time Tasks," Information Processing Letters, 11:115-118, 1980.

  16. End of lecture 6 Thank you!

More Related