Presentation is loading. Please wait.

Presentation is loading. Please wait.

Scheduling Strategies Operating Systems Spring 2004 Class #10.

Similar presentations


Presentation on theme: "Scheduling Strategies Operating Systems Spring 2004 Class #10."— 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. Ready List Ready List CPU Resource Manager Resource Manager Resources Preemption or voluntary yield AllocateRequest Done New Process process “Ready”“Running” “Blocked” process Scheduler Strategy

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 a collection 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. Ready List Ready List CPU Resource Manager Resource Manager Resources Preemption or voluntary yield AllocateRequest Done New Process process “Ready”“Running” “Blocked” process Scheduler Strategy

7 FCFS Example ArrivalCPU OrderBurst 0 350 1 125 2 475 3 250 4 75 p0p0 p1p1 p2p2 p3p3 p4p4 127512009004753500 Gantt Chart:

8 SJN Example  SJN: Guaranteed minimum average wait time. May result in starvation of large jobs. Need to know the CPU burst times. ArrivalCPU OrderBurst 0 350 1 125 2 475 3 250 4 75 p0p0 p1p1 p2p2 p3p3 p4p4 1275800450200750 Gantt Chart:

9 RR Example (w/ 50tu Time Slice) ArrivalCPU OrderBurst 0 350 1 125 2 475 3 250 4 75 p0p0 4003002001000 p4p4 p1p1 p0p0 p4p4 p3p3 p2p2 p1p1 p1p1 p2p2 p3p3 p0p0 p3p3 p2p2 p0p0 p3p3 p2p2 p0p0 p3p3 p2p2 p0p0 p2p2 p0p0 p2p2 p2p2 p2p2 p2p2 550650 7508509501050115012501275 Gantt Chart:

10 RR Example (w/ 50 tu Overhead) p0p0 5404803602401200 p4p4 p1p1 p0p0 p4p4 p3p3 p2p2 p1p1 p1p1 p2p2 p3p3 p0p0 p3p3 p2p2 p0p0 p3p3 p2p2 p0p0 p3p3 p2p2 p0p0 p2p2 p0p0 p2p2 p2p2 p2p2 p2p2 575790 910103011501270139015101535 635670 790 Gantt Chart:  Throughput, turnaround, wait, waiting and response time calculations must now include the overhead.

11 Multi-Level Queues  For i < j All processes at level i run before any process at level j.  Each list may use its own strategy. Ready List 0 Ready List 1 Ready List 2 Ready List N-1 Scheduler CPU Preemption or voluntary yield Done New Process

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. FIFO RR OTHER Scheduler CPU Done New Process Preemption or voluntary yield

13 Linux OTHER Queue Scheduling  The OTHER queue uses the following strategy: Each thread, i, has a priority p i  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 (p i --). 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 now return to the ready queue.

14 Multi-Level Feedback Queues  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 List 0 Ready List 1 Ready List 2 Ready List N-1 Scheduler CPU Preemption or voluntary yield Done New Process

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


Download ppt "Scheduling Strategies Operating Systems Spring 2004 Class #10."

Similar presentations


Ads by Google