170 likes | 405 Views
Real-Time Scheduling. CS4730 Fall 2010 Dr. Jos é M. Garrido Department of Computer Science and Information Systems Kennesaw State University. Real-Time Scheduling. Earliest Deadline First (EDF) Rate Monotonic Scheduling (RMS). Rate Monotonic Scheduling. Based on fixed priorities
E N D
Real-Time Scheduling CS4730 Fall 2010 Dr. JoséM. Garrido Department of Computer Science and Information Systems Kennesaw State University
Real-Time Scheduling • Earliest Deadline First (EDF) • Rate Monotonic Scheduling (RMS)
Rate Monotonic Scheduling • Based on fixed priorities • The shorter the period of the task, the higher the priority assigned • Example: P1 = (3, 4, 4) P2 = (2, 8, 8)
RM Scheduling P1 = (3, 4, 4) P2 = (2, 8, 8)
Least Compute Time (LCT) • Also based on fixed priorities • The shorter the compute time of the task, the higher the priority assigned • Example: P1 = (3, 4, 4) P2 = (2, 8, 8) P2 will have higher priority. P1 will missed its first deadline
RT Scheduling with Dynamic Priorities • Shortest Completion Time (SCT) • Earliest Deadline First (EDF) • Least Slack Time (LST)
Earliest Deadline First Scheduling: EDF • Based on dynamic priorities. • EDF scheme: Choose the task with the earliest (current) deadline • Preemptive: scheduling decision made when a task finishes as well as when a new task arrives • Theorem: If there is a possible schedule, then EDF will find one • Example: Two processes: P1 (2, 4, 4) and P2 (5, 10, 10)
EDF Example 1 P1 (2, 4, 4) and P2 (5, 10, 10) At times t=4 and t=12, P2 is preempted
EDF Example 2 • Task T1 with period 10 and CPU time 3 • Task T2 with period 10 and CPU time 1 • Task T3 with period 15 and CPU time 8 0 3 4 10 12 1516 20 2324 28 T1 T2 T3 T3 T1 T2 T3 T1 T2 T3
Scheduling Algorithm: RMS • Rate Monotonic Scheduling (Liu and Layland, 1973) • Based on static priorities. • Preemptive: scheduling decision made when a task finishes as well as when a new task arrives • Scheduling algorithm: Choose the task with smallest period (among ready tasks) • Theorem: If utilization is smaller than 0.7, then RMS is guaranteed to find one • If utilization is between 0.7 to 1, RMS may or may not succeed • Example:
Priority Inversion • T1 has highest priority, T2 next, and T3 lowest • T3 comes first, starts executing, and acquires some resource (say, a lock). • T1 comes next, interrupts T3 as T1 has higher priority • But T1 needs the resource locked by T3, so T1 gets blocked • T3 resumes execution • T2 arrives, and interrupts T3 as T2 has higher priority than T3, and T2 executes till completion • In effect, even though T1 has priority than T2, and arrived earlier than T2, T2 delayed execution of T1 • This is “priority inversion” !! Not acceptable. • Solution T3 should inherit T1’s priority at step 5
RM Scheduling • RM scheduling is optimal with respect to maximum utilization over all static-priority schedulers. • However, this scheduling policy only supports tasks that fit the periodic task model, since priorities depend upon request periods. • Because the request times of aperiodic tasks are not always predictable, these tasks are not supported by the RM algorithm
The EDF Scheduling • The EDF scheduling algorithm is a preemptive and dynamic priority scheduler that executes tasks in order of the time remaining before their corresponding deadlines. • Tasks with the least time remaining before their deadline are executed before tasks with more remaining time. • At each invocation of the scheduler, the remaining time is calculated for each waiting task, and the task with the least remaining time is dispatched. • If a task set is schedulable, the EDF algorithm results in a schedule that achieves optimal resource utilization.
However, EDF is shown to be unpredictable if the required utilization exceeds 100%, known as an overload condition. • EDF is useful for scheduling aperiodic tasks, since the dynamic priorities of tasks do not depend on the determinism of request periods.
EDF • Earliest deadline first (EDF) scheduling is a dynamic scheduling principle used in real-time operating systems. • It places processes in a priority queue. • Whenever a scheduling event occurs (task finishes, new task released, etc.) the queue will be searched for the process closest to its deadline. This process will then be scheduled for execution next.