550 likes | 558 Views
Explore CPU scheduling algorithms, resource reservations, and practical applications for efficient and predictable task scheduling in operating systems. Learn about CPU reservations, time constraints, and co-existing multimedia applications.
E N D
Scheduling Task vs I/O Request • Task computation time unpredictable • Task can be preemptive
CPU Scheduling Algorithm • FCFS • Priority-based • Proportional fair-share • EDF • Rate monotonic
Problem • How can multimedia applications co-exists with normal applications?
Same Idea as Cello P. Goyal, X. Guo, and H. M. Vin. “A hierarchical CPU scheduler for multimedia operating systems.” OSDI’96
Guarantee? • So far: Best-Effort Real-Time Scheduling • What about: Guaranteed service?
Resource Reservations • How to reserve? • Overbook? • Overuse?
Example: Memory • How to reserve? malloc • Overbook? return NULL • Overuse? crash, throw exception
Example: CPU • How to reserve? • Overbook? • Overuse? Memoryis discrete. CPUtimeis continuous.
CPU Reservation “I need C units of time .. out of every T units.”
Some Issues • “I need C units of time, out of every T units.”
Schedulability Theorems • Rate Monotonic Scheduler • Earliest Deadline First
Assumptions • programs are periodic • computation time is constant • zero context switch time • programs are independent
Rialto Scheduler CPU Reservations and Time Contraints: Efficient and Predictable Scheduling of Independent Activities, M. Jones, D. Rosu and M. Rosu
Why Rialto? • Provide CPU reservation • Enable deadlines • Co-exists with best-effort apps
Overview • input: a set of tasks and their reservation • pre-compute a scheduling graph • schedule tasks based on scheduling graph
B E A C B E D F B E A B E D
C A B E F D
Advantages • Only need to make new scheduling decisions when new task is added
Computing Scheduling Graph • Input: A set of tasks with their reservations • Output: A scheduling graph if feasible
Many Possible Solutions C A A B E B E F F D D C
C A F B E F D
Computing Scheduling Graph • Input: A set of tasks with their reservations • Output: A scheduling graph if feasible • Goals: (a) Minimize context switches (b) Distribute free time evenly
Life is Tough.. NP-Hard
Heuristic 10 10 10 10 10 10 10
10 5 F 5 5 10 10 10
6 1 F 1 B+E 1 6 6 6
C 4 1 F 1 B+E 1 1 1 A+D 1
Time Constraint • “I need to run the following code, that takes 30ms, 100ms from now, and the deadline is (now+180ms).”
Pseudocode can = begin_constraint(start_time, deadline, estimate) if can schedule then do work else adapt time_taken = end_constraint()
Scheduling Constraints C A F B E F D
Advantages • Only need to make new scheduling decisions when new task is added • Feasibility of time constraint can be predicted accurately
Running Unreserved Task C A F B E F D
Look inside NT Scheduler • Scheduling unit : Thread • Priority level: 1-15, 16-31 • rt 24 high 13 normal 8 idle 4
Priority Boosting • Example: • Priority +6 after awaken by keyboard input
Anti-Starvation • If hasn’t run for 3 seconds • Boost priority to 14 • Avoid “Priority Inversion”
C A F B E F D Rialto/NT Rialto Boost Priority to 30 NTScheduler
Experiment 1 • WMP running alone
Experiment 2 • WMP running with priority 8 competitor
Experiment 3 • WMP running with priority 10 competitor