scheduling
play

Scheduling CS 450: Operating Systems Michael Saelee - PowerPoint PPT Presentation

Scheduling CS 450: Operating Systems Michael Saelee <lee@iit.edu> // Scheduler never returns. It loops, doing: // Enter scheduler. // - choose a process to run void // - swtch to start running that process sched(void) // - eventually


  1. Process Arrival Time Burst Time P 1 0 7 P 2 2 4 P 3 4 1 P 4 5 4 Throughput Utilization RR q =1 0.25 1.0 RR q =3 0.25 1.0 RR q =4 0.25 1.0 RR q =7 0.25 1.0

  2. What happens when we add in context switch times?

  3. Process Arrival Time Burst Time P 1 0 7 P 2 2 4 P 3 4 1 P 4 5 4 (CST=1) Avg. Turnaround Avg. Wait Time RR q =1 20.25 13.25 RR q =3 16.25 11.25 RR q =4 11.5 7.25 RR q =7 10.25 6.25

  4. Process Arrival Time Burst Time P 1 0 7 P 2 2 4 P 3 4 1 P 4 5 4 (CST=1) Throughput Utilization RR q =1 0.125 0.5 RR q =3 0.167 0.667 RR q =4 0.19 0.762 RR q =7 0.2 0.8

  5. CST = fixed, systemic overhead - increasing quantum relative to CST amortizes the cost - shorter q = worse utilization; longer q ⟶ FIFO - NB: cost of context switches is not just the constant CST! - Also: cache flush/reload, VM swapping, etc.

  6. generally, try to choose q to help tune responsiveness 
 (i.e., of interactive jobs) may use: - predetermined burst-length threshold (for interactive jobs) - median of EMAs - process profiling

  7. RR prevents starvation, and allows both CPU-hungry and interactive jobs to share resources fairly - but at the cost of utilization and turnaround times!

  8. Can exercise more fine-grained control by introducing a system of arbitrary priorities - computed and assigned to jobs dynamically by scheduler - highest (current) priority goes next

  9. SJF is an example of a priority scheduler! - jobs are weighted using a burst-length prediction algorithm (e.g., EMA) - priorities may vary over job lifetimes

  10. Recall: SJF is prone to starvation Common issue for priority schedulers - combat with aging

  11. 4. Highest Penalty Ratio Next (HPRN) - a priority scheduler that uses aging to avoid starvation

  12. Two statistics maintained for each job: 1. total CPU execution time, t 2. “wall clock” age, T

  13. Priority, “penalty ratio” = T / t - ∞ when job is first ready - decreases as job receives CPU time

  14. HPRN in practice would incur too many context switches (due to very short bursts) — fix by instituting a minimum burst quanta (how is this different from RR?)

  15. 5. Selfish RR - a more sophisticated priority based scheduling policy

  16. holding priority ↑ α arriving active (RR) priority ↑ β CPU β = 0 : RR β ≥ ( α ≠ 0) : FCFS β > ( α = 0) : RR in batches α > β > 0 : “Selfish” (ageist) RR

  17. Another problem (on top of starvation) possibly created by priority-based scheduling policies: priority inversion

  18. Process Priority State P 1 High Ready P 2 Mid Ready P 3 Mid Ready P 4 Low Ready

  19. Process Priority State P 1 High Running P 2 Mid Ready P 3 Mid Ready P 4 Low Ready P 1 P 2 P 3 P 4 request allocated Resource

  20. Process Priority State P 1 High Blocked P 2 Mid Ready P 3 Mid Ready P 4 Low Ready P 1 P 2 P 3 P 4 request allocated Resource ( mutually exclusive allocation)

  21. Process Priority State P 1 High Blocked P 2 Mid Running P 3 Mid Ready P 4 Low Ready P 1 P 2 P 3 P 4 request allocated Resource ( mutually exclusive allocation)

  22. Process Priority State P 1 High Blocked P 2 Mid Done P 3 Mid Running P 4 Low Ready P 1 P 3 P 4 request allocated Resource ( mutually exclusive allocation)

  23. Process Priority State P 1 High Blocked P 2 Mid Done P 3 Mid Done P 4 Low Running P 1 P 4 request allocated Resource ( mutually exclusive allocation)

  24. Process Priority State P 1 High Blocked P 2 Mid Done P 3 Mid Done P 4 Low Done P 1 request Resource ( mutually exclusive allocation)

  25. Process Priority State P 1 High Ready P 2 Mid Done P 3 Mid Done P 4 Low Done P 1 a l l o c a t e d Resource ( mutually exclusive allocation)

  26. Process Priority State P 1 High Running P 2 Mid Done P 3 Mid Done P 4 Low Done P 1 a l l o c a t e d Resource ( mutually exclusive allocation)

  27. priority inversion : a high priority job effectively takes on the priority of a lower-level one that holds a required resource

  28. high profile case study: NASA Pathfinder - spacecraft developed a recurring system failure/reset - occurred after deploying robot to surface of Mars

  29. culprits: - flood of meteorological data - low priority of related job: ASI/MET - a shared, mutually exclusive resource (semaphore guarding an IPC pipe)

  30. high priority job (for data aggregation & distribution) — bc_dist — required pipe - but always held by ASI/MET - in turn kept from running by various mid-priority jobs

  31. scheduling job determined that bc_dist couldn’t complete per hard deadline - declared error resulting in system reset! - re-produced in lab after 18-hours of on-Earth simulation

  32. fix: priority inheritance - job blocking a higher priority job will inherit the latter’s priority - e.g., run ASI/MET at bc_dist’s priority until resource released

  33. how? - enabling priority inheritance via semaphores (in vxWorks) - (why wasn’t it on by default?) - prescient remote tracing/patching facilities built in to system

  34. why did NASA not foresee this? “Our before launch testing was limited to the “best case” high data rates and science activities… We did not expect nor test the “better than we could have ever imagined” case.” - Glenn Reeves 
 Software team lead

  35. takeaways: - scheduling bugs are hard to predict, track down, and fix - priority inheritance provides a “solution” for priority inversion - scheduling is rocket science!

  36. questions: - w.r.t. priority inheritance: - pros/cons? - how to implement? - w.r.t. priority inversion: - detection? how else to “fix”? - effect on non-real-time OS?

  37. Even with fine-grained control offered by a priority scheduler, hard to impose different sets of goals on groups of jobs E.g., top-priority for system jobs, RR for interactive jobs, FCFS for batch jobs

  38. 6. Multi-Level Queue (MLQ) - disjoint ready queues - separate schedulers/policies for each

  39. system Fixed priority interactive RR (small q) normal RR (larger q) batch FCFS

  40. requires queue arbitration strategy in place

Recommend


More recommend