1 / 16

Scheduling Strategies

Scheduling Strategies. Operating Systems Spring 2004 Class #10. Scheduling Strategies. The job of the scheduling strategy is to select the next Ready process to enter the Running state. Preemption or voluntary yield. Scheduler. Strategy. New Process. Ready List. CPU. Done. process.

alodie
Download Presentation

Scheduling Strategies

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. Scheduling Strategies Operating Systems Spring 2004 Class #10

  2. Scheduling Strategies • The job of the scheduling strategy is to select the next Ready process to enter the Running state. Preemption or voluntary yield Scheduler Strategy New Process Ready List CPU Done process process process “Ready” process “Running” Resource Manager Allocate Request process process process “Blocked” Resources

  3. Some Scheduling Strategies • Non-Preemptive Strategies: • First-Come-First-Served (FCFS) • Priority* • Shortest Job Next (SJN)* * These also come in a preemptive flavor. • Preemptive Strategies: • Round Robin • Multi-level Queue • Multi-level Feedback Queue

  4. Evaluating Scheduling Strategies • Some metrics that are useful in evaluating scheduling strategies: • CPU Utilization: The percentage of time that the CPU spends executing code on behalf of a user. • Throughput: The average number of processes completed per time unit. • Turnaround Time*: The total time from when a process first enters the Ready state to last time it leaves the Running state. • Wait Time*: The time a process spends in the Ready state before its first transition to the Running state. • Waiting Time*: The total time that a process spends in the Ready state. • Response Time*: The average amount of time that a process spends in the Ready state. * These metrics are typically averaged across acollection of processes.

  5. Comparing Scheduling Strategies • There are many techniques for comparing scheduling strategies: • Deterministic Modeling • Queuing Models • Simulation • Implementation

  6. Deterministic Modeling • In deterministic modeling we’ll ignore I/O operations and voluntary yields. Preemptionor voluntary yield Scheduler Strategy New Process Ready List CPU Done process process process “Ready” process “Running” Resource Manager Allocate Request process process process “Blocked” Resources

  7. Arrival CPU Order Burst 0 350 1 125 2 475 3 250 4 75 FCFS Example Gantt Chart: 0 350 475 900 1200 1275 p0 p1 p2 p3 p4

  8. Arrival CPU Order Burst 0 350 1 125 2 475 3 250 4 75 SJN Example • SJN: • Guaranteed minimum average wait time. • May result in starvation of large jobs. • Need to know the CPU burst times. Gantt Chart: 0 75 200 450 800 1275 p4 p1 p3 p0 p2

  9. Arrival CPU Order Burst 0 350 1 125 2 475 3 250 4 75 RR Example (w/ 50tu Time Slice) Gantt Chart: 0 100 200 300 400 475 550 650 p0 p1 p2 p3 p4 p0 p1 p2 p3 p4 p0 p1 p2 p3 650 750 850 950 1050 1150 1250 1275 p0 p2 p3 p0 p2 p3 p0 p2 p0 p2 p2 p2 p2

  10. RR Example (w/ 50 tu Overhead) • Throughput, turnaround, wait, waiting and response time calculations must now include the overhead. Gantt Chart: 0 120 240 360 480 540 575 635 670 790 p0 p1 p2 p3 p4 p0 p1 p2 p3 p4 p0 p1 p2 p3 790 910 1030 1150 1270 1390 1510 1535 p0 p2 p3 p0 p2 p3 p0 p2 p0 p2 p2 p2 p2

  11. Multi-Level Queues Preemption or voluntary yield • For i < j All processes at level i run before any process at level j. • Each list may use its own strategy. Ready List0 Scheduler Ready List1 CPU Done Ready List2 New Process Ready ListN-1

  12. Linux Scheduling • Linux uses a multi-level queue scheduling strategy: • All threads in FIFO run before any in RR which run before any in OTHER. • Within each queue a priority scheme is used with higher priority threads running first. • User threads run in the OTHER queue. • All queues are preemptive. Preemption or voluntary yield FIFO Done New Process Scheduler RR CPU OTHER

  13. Linux OTHER Queue Scheduling • The OTHER queue uses the following strategy: • Each thread, i, has a priority pi • Every new thread is given a default priority, K. • A countdown timer is used to create time slices. • On each timer interrupt the priority of the running thread is decremented (pi--). • When a thread’s priority reaches 0, it is blocked. • The highest priority thread is selected to run for the next time slice. • If no threads are available (i.e. all threads are blocked on a resource or because they have 0 priority), then a recrediting operation is performed. • During recrediting, every thread in the system is assigned priority using the following formula: • Threads blocked for 0 priority nowreturn to the ready queue.

  14. Multi-Level Feedback Queues Preemption or voluntary yield • For i < j All processes at level i run before any process at level j. • Processes are inserted into queues by priority. • Process priorities are updated dynamically. • Each queue typically uses a RR strategy. • Popular in Modern OS: • Windows • BSD Ready List0 Scheduler Ready List1 CPU Done Ready List2 New Process Ready ListN-1

  15. Scheduling Simulations • Scheduling simulations account for several important factors that are frequently ignored by deterministic modeling: • Scheduling Overhead • I/O Operations • Process Profiles: • CPU Bound • I/O Bound • Variable process arrival times.

  16. Project • Implement the RR and Linux OTHER scheduling strategies and compare their performance on: • I/O Bound Processes • CPU Bound Processes • A mix of CPU and I/O Bound Processes

More Related