1 / 55

CPU Scheduling

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.

lpearl
Download Presentation

CPU 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. CPU Scheduling

  2. Scheduling Task vs I/O Request • Task computation time unpredictable • Task can be preemptive

  3. CPU Scheduling Algorithm • FCFS • Priority-based • Proportional fair-share • EDF • Rate monotonic

  4. Rate Monotonic

  5. EDF

  6. Problem • How can multimedia applications co-exists with normal applications?

  7. Same Idea as Cello P. Goyal, X. Guo, and H. M. Vin. “A hierarchical CPU scheduler for multimedia operating systems.” OSDI’96

  8. Guarantee? • So far: Best-Effort Real-Time Scheduling • What about: Guaranteed service?

  9. How to Guarantee Services?

  10. Resource Reservation: CPU

  11. Resource Reservations • How to reserve? • Overbook? • Overuse?

  12. Example: Memory • How to reserve? malloc • Overbook? return NULL • Overuse? crash, throw exception

  13. Example: CPU • How to reserve? • Overbook? • Overuse? Memoryis discrete. CPUtimeis continuous.

  14. How to Reserve?

  15. CPU Reservation “I need C units of time .. out of every T units.”

  16. Some Issues • “I need C units of time, out of every T units.”

  17. Effects of T and C

  18. Effects of T and C

  19. Schedulability Theorems • Rate Monotonic Scheduler • Earliest Deadline First

  20. Assumptions • programs are periodic • computation time is constant • zero context switch time • programs are independent

  21. Rialto Scheduler CPU Reservations and Time Contraints: Efficient and Predictable Scheduling of Independent Activities, M. Jones, D. Rosu and M. Rosu

  22. Why Rialto? • Provide CPU reservation • Enable deadlines • Co-exists with best-effort apps

  23. Overview • input: a set of tasks and their reservation • pre-compute a scheduling graph • schedule tasks based on scheduling graph

  24. B E A C B E D F B E A B E D

  25. C A B E F D

  26. Advantages • Only need to make new scheduling decisions when new task is added

  27. Computing Scheduling Graph • Input: A set of tasks with their reservations • Output: A scheduling graph if feasible

  28. Many Possible Solutions C A A B E B E F F D D C

  29. C A F B E F D

  30. 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

  31. Life is Tough.. NP-Hard

  32. Heuristic 10 10 10 10 10 10 10

  33. 10 5 F 5 5 10 10 10

  34. 6 1 F 1 B+E 1 6 6 6

  35. C 4 1 F 1 B+E 1 1 1 A+D 1

  36. Time Constraint • “I need to run the following code, that takes 30ms, 100ms from now, and the deadline is (now+180ms).”

  37. Pseudocode can = begin_constraint(start_time, deadline, estimate) if can schedule then do work else adapt time_taken = end_constraint()

  38. Scheduling Constraints C A F B E F D

  39. Advantages • Only need to make new scheduling decisions when new task is added • Feasibility of time constraint can be predicted accurately

  40. Running Unreserved Task C A F B E F D

  41. Media Player on Rialto/NT

  42. Look inside NT Scheduler • Scheduling unit : Thread • Priority level: 1-15, 16-31 • rt 24 high 13 normal 8 idle 4

  43. Priority Boosting • Example: • Priority +6 after awaken by keyboard input

  44. Anti-Starvation • If hasn’t run for 3 seconds • Boost priority to 14 • Avoid “Priority Inversion”

  45. Mars Pathfinder

  46. C A F B E F D Rialto/NT Rialto Boost Priority to 30 NTScheduler

  47. Win Media Player 6.4

  48. Experiment 1 • WMP running alone

  49. Experiment 2 • WMP running with priority 8 competitor

  50. Experiment 3 • WMP running with priority 10 competitor

More Related