Download presentation
Presentation is loading. Please wait.
1
1 Scheduling Algorithms FCFS First-Come, First-Served Round-robin SJF Multilevel Feedback Queues
2
2 Round-Robin Scheduling Quantum expires: move to back of ready queue Variants used in most real systems Tradeoffs: length of quantum Large: response time increases Small: throughput decreases quantum → 0 = overhead dominates context switches, cache misses
3
3 Example: Round-Robin waiting running
4
4 Example: Round-Robin waiting running
5
5 Example: Round-Robin waiting running
6
6 Example: Round-Robin waiting running
7
7 Example: Round-Robin waiting running
8
8 Example: Round-Robin waiting running
9
9 Example: Round-Robin waiting running
10
10 Example: Round-Robin waiting running
11
11 Example: Round-Robin waiting running
12
12 Example: Round-Robin waiting running
13
13 Example: Round-Robin waiting running + Fair - Long average wait times
14
14 Round-Robin vs. FCFS Example 1: 5 jobs, 100 seconds each, quantum = 1s ignore context switch time
15
15 Round-Robin vs. FCFS Example 1: 5 jobs, 100 seconds each, quantum = 1s ignore context switch time
16
16 Round-Robin vs. FCFS Example 2: 5 jobs: 50, 40, 30, 20, 10 seconds each, quantum = 1s
17
17 Round-Robin vs. FCFS Example 2: 5 jobs: 50, 40, 30, 20, 10 seconds each, quantum = 1s
18
18 This Time: Scheduling Algorithms FCFS First-Come, First-Served Round-robin SJF Multilevel Feedback Queues
19
19 Example: SJF 50 40 30 20 10 Schedule job with least work until I/O or done 0103060100150
20
20 Example: SJF 50 40 30 20 10 Schedule job with least work until I/O or done 0103060100150
21
21 Example: SJF 50 40 30 20 10 Schedule job with least work until I/O or done 0103060100150
22
22 Example: SJF 50 40 30 20 10 Schedule job with least work until I/O or done 0103060100150
23
23 Example: SJF 50 40 30 20 10 Schedule job with least work until I/O or done 0103060100150
24
24 Example: SJF 50 40 30 20 10 0 3060100150 Schedule job with least work until I/O or done
25
25 Example: SJF 5 jobs, length 50, 40, 30, 20, 10 seconds, quantum = 1s
26
26 Example: SJF 5 jobs, length 50, 40, 30, 20, 10 seconds
27
27 SJF/SRTF: Shortest-Job First Advantages: Provably optimal – minimizes average waiting time Works for preemptive & non-preemptive schedulers Preemptive SJF = SRTF Shortest remaining time first Disadvantages: Impossible to predict CPU time job has left Long-running CPU-bound jobs can starve
28
28 This Time: Scheduling Algorithms FCFS First-Come, First-Served Round-robin SJF Multilevel Feedback Queues
29
29 Multilevel Feedback Queues (MLFQ) Use past behavior to predict future, assign job priorities Overcome prediction problem in SJF Assumption: I/O-bound in past, I/O-bound in future Scheduler favors jobs that used least CPU time Adaptive: Change in behavior → change in scheduling decisions
30
30 MLFQ: Approximating SJF Multiple queues, different priorities Round-robin scheduling at each priority level Run all jobs at highest priority first (till this queue is empty), then next, etc. Can lead to starvation Increase quantum exponentially at lower priorities
31
31 MLFQ Example
32
32 MLFQ: Assigning Priorities Job starts in highest priority queue Quantum expires → CPU-bound Drop priority one level Quantum does not expire → I/O-bound Increase priority one level CPU-bound jobs move down, I/O-bound jobs move up
33
33 Summary of Scheduling Algorithms FCFS: unfair, average waiting time poor Round robin: fair, average waiting time poor SJF: unfair, minimizes average waiting time requires accurate prediction Multilevel Feedback Queuing: approximates SJF
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.