![Page 2: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/2.jpg)
Overview
2
![Page 3: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/3.jpg)
• Scheduling:
• Policies & mechanisms used to allocate a resource to some set of entities.
3
![Page 4: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/4.jpg)
• Resources & entities: CPU & processes
• Other possibilities:
• Resources: memory, I/O bus/devices
• Entities: threads, users, groups
4
![Page 5: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/5.jpg)
• Policy: high-level “what”
• AKA: Scheduling disciplines
• Mechanism: low-level “how”
• E.g., interrupts, context switches, etc.
5
![Page 6: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/6.jpg)
You can’t know “how” unless you know “why”.
We’ll start with policy.
6
![Page 7: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/7.jpg)
• Basic idea:
• CPU(s) are a limited resource
• Efficiently allow for time-sharing of CPU(s) amongst multiple processes
• Enables concurrency on a single CPU
7
![Page 8: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/8.jpg)
At a high level (policy), we’re only concerned with macro process state
One of: running, ready, or blocked
8
![Page 9: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/9.jpg)
Running = consuming CPU
Ready = “Runnable”, but not running
Blocked = Not runnable (e.g., waiting for I/O)
9
![Page 10: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/10.jpg)
10
Ready Blocked
Ready Blocked
Running
creation
completion
scheduled I/O request (trap/syscall)
I/O completion
swap in/outswap in/out
preemption
![Page 11: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/11.jpg)
Preemptive Scheduling
Running → Ready transition
11
![Page 12: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/12.jpg)
Non-preemptive scheduling
Running ↛ Ready transition
12
i.e., not = batch!
![Page 13: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/13.jpg)
• Domain of the “swapper” — separate from the CPU scheduler
• Frequency in seconds vs. ms
• Ignore for now
13
Ready Blocked
![Page 14: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/14.jpg)
• Convenient to envision a ready queue/set
• Scheduling policy is used to select the next running process from the ready queue
14
Ready
Runningscheduled
![Page 15: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/15.jpg)
• Policies vary by:
• Preemptive vs. non-preemptive
• Factors used in selecting a process
• Goals; that is, why are we selecting a given process?
15
![Page 16: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/16.jpg)
Jobs
Users
Waiting Queue
J4 J3 J2J1
Selection of jobs into window based on fairness
J0
Scheduling Window
J3 J2 J1J0
Scheduler(FCFS/0-1 Knapsack)
Allocation of jobs based on power consumption, system utilization, etc.
Dynamic Learner
Job & Group Profiler
Profiling Tool(e.g., MonEQ)
BONUS SLIDE16
![Page 17: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/17.jpg)
Scheduling goals are usually predicated on optimizing certain scheduling metrics
Can be provable or based on heuristics!
17
![Page 18: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/18.jpg)
Scheduling Metrics
18
![Page 19: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/19.jpg)
• Metrics we will be concerned with:
• Turnaround time
• Wait time
• Response time
• Throughput
• Utilization
19
![Page 20: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/20.jpg)
Turnaround time:
Tturnaround = Tcompletion - Tcreation
Total time to complete process (or “job”)
20
![Page 21: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/21.jpg)
• Turnaround time depends on much more than the scheduling discipline!
• Process runtime
• Process I/O processing time
• How many CPUs are available
• How many other processes need to run
21
![Page 22: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/22.jpg)
• Wait time: time spent in ready queue
• That is, how long does the scheduler force a runnable process to wait for a CPU
• Better gauge of scheduler’s effectiveness
22
![Page 23: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/23.jpg)
• Turnaround & wait times are measured over the course of an entire process — sometimes referred to as the “job”
• Not at all useful as a metric for interactive processes
• (Expectedly?) alternate between CPU & I/O bursts, indefinitely
23
![Page 24: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/24.jpg)
“bursty” execution24
![Page 25: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/25.jpg)
Burst length histogram(it’s terrible)
25
![Page 26: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/26.jpg)
• Taking measurements per-burst?
• That is, from first entry into ready queue to completion or transition to blocked
• Burst turnaround time, aka response time
• Burst wait time
26
![Page 27: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/27.jpg)
• Throughput
• Number of completed jobs or bursts per time unit (e.g., N/sec)
27
![Page 28: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/28.jpg)
• Utilization
• % of time the CPU is doing “work” (running jobs)
• Note: CPU can be idle if there are no active jobs or if all jobs are blocked!
28
![Page 29: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/29.jpg)
• Another (subjective, yet important!) metric: fairness
• What does this mean (and to whom)?
• How to measure it?
• Is it useful?
29
![Page 30: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/30.jpg)
Scheduling Policies
30
![Page 31: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/31.jpg)
1. First Come, First Served
31
![Page 32: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/32.jpg)
Process Arrival Time Burst Time
P1 0 24
P2 0 3
P3 0 3
32
P1 P2 P30 24 27 30
Wait times: P1 = 0, P2 = 24, P3 = 27 Average: (0+25+27)/3 = 17
“Gantt Chart”
![Page 33: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/33.jpg)
Convoy Effect© WB Studios
33
![Page 34: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/34.jpg)
Process Arrival Time Burst Time
P1 0 24
P2 0 3
P3 0 3
34
P3 P2 P10 3 6 30
Wait times: P1 = 6, P2 = 3, P3 = 0 Average: (6+3+0)/3 = 3
“Gantt Chart”
![Page 35: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/35.jpg)
2. Shortest Job First
35
![Page 36: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/36.jpg)
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
36
Non-Preemptive SJF
P1 P3 P2 P4
P2 waits
P3 waits
P4 waits
![Page 37: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/37.jpg)
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
37
Wait times: P1 = 0, P2 = 6, P3 = 3, P4 = 7 Average: (0+6+3+7)/4 = 4
P1 P3 P2 P4
P2 waits
P3 waits
P4 waits
![Page 38: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/38.jpg)
Can we do better?
38
![Page 39: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/39.jpg)
Yes! (theoretically): Preemptive SJF
a.k.a. Shortest-Remaining-Time-First
39
![Page 40: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/40.jpg)
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
40
P1 P4 P1
P1 waits
P2 waits
P4 waits
P2 P3 P2
![Page 41: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/41.jpg)
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
41
P1 P4 P1
P1 waits
P2 waits
P4 waits
P2 P3 P2
Wait times: P1 = 9, P2 = 1, P3 = 0, P4 = 2 Average: (9+1+0+2)/4 = 3
![Page 42: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/42.jpg)
SJF/SRTF are greedy algorithms;
i.e., they always elect the local optima
Greedy algorithm don’t always produce globally optimal results (e.g., hill-climbing).
42
![Page 43: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/43.jpg)
Consider 4 jobs arriving at t = 0, with burst length t0, t1, t2, t3
Average wait time if scheduled in order?
43
=3t0 + 2t1 + t2
4
![Page 44: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/44.jpg)
—a weighted average; clearly minimized by running shortest jobs first.
That is, SJF/PSJF are provably optimal with respect to wait time!
44
=3t0 + 2t1 + t2
4
![Page 45: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/45.jpg)
At what cost?
…potential starvation!
(possible for both non-preemptive & preemptive variants)
45
![Page 46: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/46.jpg)
Also, we’ve been making two simplifying assumptions:
1. Context switch time = 0
2. Burst lengths are known in advance
46
![Page 47: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/47.jpg)
(1) will be dealt with later;
(2) is a serious problem!
47
![Page 48: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/48.jpg)
• Typically predict future burst lengths based on past job behavior
• Simple moving average
• Exponentially weighted moving average (EMA)
48
![Page 49: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/49.jpg)
Observed:
Estimated:
Weight (⍺):
EMA:
49
⇢n�1
�n�1
0 ↵ 1
�n = ↵ · ⇢n�1 + (1� ↵) · �n�1
![Page 50: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/50.jpg)
50
Actual Avg (3) Error EMA Error
4.00 5.00 1.00 5.00 1.005.00 4.00 1.00 4.80 0.20
5.00 4.50 0.50 4.84 0.166.00 4.67 1.33 4.87 1.13
13.00 5.33 7.67 5.10 7.90
12.00 8.00 4.00 6.68 5.3211.00 10.33 0.67 7.74 3.266.00 12.00 6.00 8.39 2.39
7.00 9.67 2.67 7.92 0.925.00 8.00 3.00 7.73 2.73
Avg err: 2.78 2.50
EMA Alpha: 0.20
0.00
3.25
6.50
9.75
13.00Actual Avg (3) EMA
![Page 51: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/51.jpg)
How to deal with starvation?
One way: enforce fairness
51
![Page 52: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/52.jpg)
3. Round Robin: the “fairest” of them all
• FIFO queue
• Each job runs for max time quantum
• If unfinished, re-enter queue at back
52
![Page 53: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/53.jpg)
• Given time quantum q and n jobs:
• Max wait time =
• Each job receives 1/n timeshare
53
q · (n� 1)
![Page 54: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/54.jpg)
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
54
P1
P2 waits
P3 waits
P4 waits
Round Robin, q = 3
P2 P1 P3 P4 P2 P1 P4
P1 waits
P2 waits
P1 waits
P4 waits
![Page 55: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/55.jpg)
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
55
P1
P2 waits
P3 waits
P4 waits
P2 P1 P3 P4 P2 P1 P4
P1 waits
P2 waits
P1 waits
P4 waits
Wait times: P1 = 8, P2 = 8, P3 = 5, P4 = 7 Average: (8+8+5+7)/4 = 7
![Page 56: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/56.jpg)
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
56
Average Turnaround Average Wait Time
RR q = 1 9.75 5.75
RR q = 3 11 7
RR q = 4 9 5
RR q = 7 8.75 4.75
![Page 57: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/57.jpg)
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
57
(CST=1) Average Turnaround Average Wait Time
RR q = 1 20.25 13.25
RR q = 3 16.25 11.25
RR q = 4 11.50 7.25
RR q = 7 10.25 6.25
![Page 58: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/58.jpg)
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
58
(CST=1) Throughput Utilization
RR q = 1 0.125 0.500
RR q = 3 0.167 0.667
RR q = 4 0.190 0.762
RR q = 7 0.200 0.800
![Page 59: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/59.jpg)
q large ⇒ FIFO
q small ⇒ big CST overhead
59
![Page 60: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/60.jpg)
• Generally, try to tune q to help tune responsiveness (i.e., of interactive processes)
• May use:
• Predetermined max response threshold
• Median of EMAs
• Process profiling
60
![Page 61: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/61.jpg)
RR permits CPU-hungry jobs to run periodically, but prevent them from monopolizing the system (compared to FCFS and SJF)
…but also introduces inflexible systematic overhead: context switching
61
![Page 62: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/62.jpg)
Fairness is overrated!
62
![Page 63: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/63.jpg)
• Can exercise more fine-grained control by introducing a system of arbitrary priorities
• Computed and assigned to jobs dynamically by the scheduler
• Highest (current) priority goes next
63
![Page 64: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/64.jpg)
• 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
64
![Page 65: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/65.jpg)
• Recall: SJF is prone to starvation
• Common issue for priority schedulers
• Combat with priority aging
65
![Page 66: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/66.jpg)
4. Highest Penalty Ratio Next
• Example of a priority scheduler that uses aging to avoid starvation
66
![Page 67: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/67.jpg)
• Two statistics maintained for each job:
• Total CPU execution time, t
• “Wall clock” age, T
67
![Page 68: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/68.jpg)
• Priority, “penalty ratio” = T / t
• ∞ when job is first ready
•Decreases as job receives CPU time
68
![Page 69: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/69.jpg)
• HPRN in practice would incur too many context switches (due to very short bursts)
• Likely institute minimum burst quanta
69
![Page 70: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/70.jpg)
5. Selfish Round Robin
• Example of a more sophisticated priority based scheduling policy
70
![Page 71: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/71.jpg)
71
priority ↑ ⍺
priority ↑ β
arrivingholding
active (RR)CPU
β = 0: β ≥ (⍺ ≠ 0): β > (⍺ = 0): ⍺ > β > 0:
RRFCFSRR in batches“Selfish” (ageist) RR
![Page 72: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/72.jpg)
Another problem (on top of starvation) possibly created by priority-based scheduling policies: priority inversion
72
![Page 73: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/73.jpg)
73
Process Priority State
P1 High Ready
P2 Medium Ready
P3 Medium Ready
P4 Low Ready
![Page 74: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/74.jpg)
74
Process Priority State
P1 High Running
P2 Medium Ready
P3 Medium Ready
P4 Low Ready
P1 P2 P3 P4
Resource
requestallocated
![Page 75: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/75.jpg)
75
Process Priority State
P1 High Blocked
P2 Medium Ready
P3 Medium Ready
P4 Low Ready
P1 P2 P3 P4
Resource
requestallocated
(mutually exclusive allocation)
![Page 76: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/76.jpg)
76
Process Priority State
P1 High Blocked
P2 Medium Running
P3 Medium Ready
P4 Low Ready
P1 P2 P3 P4
Resource
requestallocated
(mutually exclusive allocation)
![Page 77: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/77.jpg)
77
Process Priority State
P1 High Blocked
P2 Medium Done
P3 Medium Running
P4 Low Ready
P1 P3 P4
Resource
requestallocated
(mutually exclusive allocation)
![Page 78: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/78.jpg)
78
Process Priority State
P1 High Blocked
P2 Medium Done
P3 Medium Done
P4 Low Running
P1 P4
Resource
requestallocated
(mutually exclusive allocation)
![Page 79: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/79.jpg)
79
Process Priority State
P1 High Blocked
P2 Medium Done
P3 Medium Done
P4 Low Done
P1
Resource
request
(mutually exclusive allocation)
![Page 80: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/80.jpg)
80
Process Priority State
P1 High Ready
P2 Medium Done
P3 Medium Done
P4 Low Done
P1
Resource
allocated
(mutually exclusive allocation)
![Page 81: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/81.jpg)
81
Process Priority State
P1 High Running
P2 Medium Done
P3 Medium Done
P4 Low Done
P1
Resource
allocated
(mutually exclusive allocation)
![Page 82: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/82.jpg)
Priority inversion: a high priority job effectively take on the priority of a lower-level one that holds a required resource
82
![Page 83: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/83.jpg)
• High profile case study: NASA Pathfinder
• Spacecraft developed a recurring system failure/reset
• Occurred after deploying data-gathering robot to surface of Mars
83
![Page 84: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/84.jpg)
• Culprits:
• Flood of meteorological data
• Low priority of related job: ASI/MET
• A shared, mutually exclusive resource (semaphore guarding an IPC pipe)
84
![Page 85: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/85.jpg)
• 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
85
![Page 86: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/86.jpg)
• 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 simulating spacecraft activities
86
![Page 87: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/87.jpg)
• Fix: priority inheritance
• Job that blocks a higher priority job will inherit the latter’s priority
• E.g., run ASI/MET at bc_dist’s priority until resource is released
87
![Page 88: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/88.jpg)
• How?
• Enabling priority inheritance via semaphores (in vxWorks OS)
• (Why wasn’t it on by default?)
• Prescient remote (!) tracing & patching facilities built into system
88
![Page 89: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/89.jpg)
Why did NASA not foresee this?
89
“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
![Page 90: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/90.jpg)
• Takeaways:
• Scheduling bugs are hard to predict, track down, and fix
• Priority inheritance provides a “solution” for priority inversion
• Scheduling is rocket science!
90
![Page 91: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/91.jpg)
• Questions:
• With respect to priority inheritance:
• Pros/cons?
• How to implement?
• With respect to priority inversion:
• Detection? How else to “fix”?
• Effect on non-real-time OS?
91
![Page 92: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/92.jpg)
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.
92
![Page 93: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/93.jpg)
6. Multi-level Queue (MLQ)
• Disjoint ready queues
• Separate schedulers/policies for each
93
![Page 94: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/94.jpg)
94
system
interactive
normal
batch
Fixed priority
RR (small q)
RR (larger q)
FCFS
![Page 95: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/95.jpg)
Requires queue arbitration strategy in place
95
![Page 96: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/96.jpg)
96
system
interactive
normal
batch
Fixed priority
RR (small q)
RR (larger q)
FCFS
Approach 1: prioritize top, non-empty queue
decr
easi
ng p
riorit
y
![Page 97: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/97.jpg)
97
system
interactive
normal
batch
Fixed priority
RR (small q)
RR (larger q)
FCFS
Approach 2: aggregate time slices
50%
30%
15%
5%
![Page 98: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/98.jpg)
• What processes go in which queues?
• Self-assigned
• E.g., UNIX “nice” value
• “Profiling” based on initial burst(s)
• CPU, I/O burst length
• E.g., short, intermittent CPU bursts⇒ classify as interactive job
98
![Page 99: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/99.jpg)
• Classification issue: what if process characteristics change dynamically?
• E.g., photo editor: tool selection (interactive) → apply filter (CPU hungry) → simple edits (interactive)
99
![Page 100: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/100.jpg)
7. Multi-Level Feedback Queue
• Supports movement between queues after initial assignment
• Based on ongoing job accounting
100
![Page 101: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/101.jpg)
101
RR (q = 2)
RR (q = 4)
RR (q = 8)
e.g., 3 RR queues with different q
assignment based on q/burst-length fit
![Page 102: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/102.jpg)
102
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
0
RR (q = 2)RR (q = 4)RR (q = 8)
![Page 103: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/103.jpg)
103
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
0
RR (q = 2)RR (q = 4)RR (q = 8)
P1
P1
![Page 104: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/104.jpg)
104
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
0
RR (q = 2)RR (q = 4)RR (q = 8)
P1
P1
P2
P2
![Page 105: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/105.jpg)
105
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
0
RR (q = 2)RR (q = 4)RR (q = 8)
P1
P1
P3
P2
P2
P3
![Page 106: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/106.jpg)
106
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
0
RR (q = 2)RR (q = 4)RR (q = 8)
P1
P1
P4
P2
P2
P3 P4
![Page 107: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/107.jpg)
107
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
0
RR (q = 2)RR (q = 4)RR (q = 8)
P1
P1P4
P2
P2
P3 P4 P1
![Page 108: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/108.jpg)
108
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
0
RR (q = 2)RR (q = 4)RR (q = 8)
P1
P2
P1
P2
P4
P3 P4 P1 P2
![Page 109: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/109.jpg)
109
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
0
RR (q = 2)RR (q = 4)RR (q = 8)
P1
P4
P1
P2 P3 P4 P1 P2 P4
![Page 110: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/110.jpg)
110
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
0
RR (q = 2)RR (q = 4)RR (q = 8)
P1
P1
P2 P3 P4 P1 P2 P4 P1
![Page 111: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/111.jpg)
111
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
0
P1 P2 P3 P4 P1 P2 P4 P1
Wait times: P1 = 9, P2 = 7, P3 = 0, P4 = 6 Average: (9+7+0+6)/4 = 5.5 (vs 7 for RR, q = 3)
![Page 112: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/112.jpg)
• Following I/O, processes return to previously assigned queue
• When to move up?
• For RR, when burst ≤ q
112
![Page 113: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/113.jpg)
113
0
RR (q = 2)RR (q = 4)RR (q = 8)
e.g., Pflaky arrives at t = 0 CPU burst lengths = 7, 4, 1, 4 (I/O between)
![Page 114: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/114.jpg)
114
0
RR (q = 2)RR (q = 4)RR (q = 8)
e.g., Pflaky arrives at t = 0 CPU burst lengths = 7, 4, 1, 4 (I/O between)
Pf
Pf
![Page 115: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/115.jpg)
115
0
RR (q = 2)RR (q = 4)RR (q = 8)
e.g., Pflaky arrives at t = 0 CPU burst lengths = 7, 4, 1, 4 (I/O between)
Pf
Pf Pf
![Page 116: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/116.jpg)
116
0
RR (q = 2)RR (q = 4)RR (q = 8)
e.g., Pflaky arrives at t = 0 CPU burst lengths = 7, 4, 1, 4 (I/O between)
Pf
Pf Pf Pf
![Page 117: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/117.jpg)
117
0
RR (q = 2)RR (q = 4)RR (q = 8)
e.g., Pflaky arrives at t = 0 CPU burst lengths = 7, 4, 1, 4 (I/O between)
Pf
Pf Pf Pf(I/O)
![Page 118: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/118.jpg)
118
0
RR (q = 2)RR (q = 4)RR (q = 8)
e.g., Pflaky arrives at t = 0 CPU burst lengths = 7, 4, 1, 4 (I/O between)
Pf Pf Pf(I/O)
![Page 119: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/119.jpg)
119
0
RR (q = 2)RR (q = 4)RR (q = 8)
e.g., Pflaky arrives at t = 0 CPU burst lengths = 7, 4, 1, 4 (I/O between)
Pf
Pf Pf Pf(I/O)
Pf
![Page 120: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/120.jpg)
120
0
RR (q = 2)RR (q = 4)RR (q = 8)
e.g., Pflaky arrives at t = 0 CPU burst lengths = 7, 4, 1, 4 (I/O between)
Pf
Pf Pf Pf(I/O)
Pf
![Page 121: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/121.jpg)
121
0
RR (q = 2)RR (q = 4)RR (q = 8)
e.g., Pflaky arrives at t = 0 CPU burst lengths = 7, 4, 1, 4 (I/O between)
Pf Pf Pf(I/O)
Pf
![Page 122: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/122.jpg)
122
0
RR (q = 2)RR (q = 4)RR (q = 8)
e.g., Pflaky arrives at t = 0 CPU burst lengths = 7, 4, 1, 4 (I/O between)
Pf Pf Pf(I/O)
Pf
Pf
Pf
![Page 123: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/123.jpg)
123
0
RR (q = 2)RR (q = 4)RR (q = 8)
e.g., Pflaky arrives at t = 0 CPU burst lengths = 7, 4, 1, 4 (I/O between)
Pf Pf Pf(I/O)
Pf
Pf
Pf
![Page 124: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/124.jpg)
124
0
RR (q = 2)RR (q = 4)RR (q = 8)
e.g., Pflaky arrives at t = 0 CPU burst lengths = 7, 4, 1, 4 (I/O between)
Pf Pf Pf(I/O)
Pf Pf
![Page 125: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/125.jpg)
125
0
RR (q = 2)RR (q = 4)RR (q = 8)
e.g., Pflaky arrives at t = 0 CPU burst lengths = 7, 4, 1, 4 (I/O between)
Pf Pf Pf(I/O)
Pf Pf Pf
Pf
![Page 126: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/126.jpg)
126
0
RR (q = 2)RR (q = 4)RR (q = 8)
e.g., Pflaky arrives at t = 0 CPU burst lengths = 7, 4, 1, 4 (I/O between)
Pf Pf Pf(I/O)
Pf Pf Pf
Pf
Pf
![Page 127: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/127.jpg)
127
0
RR (q = 2)RR (q = 4)RR (q = 8)
e.g., Pflaky arrives at t = 0 CPU burst lengths = 7, 4, 1, 4 (I/O between)
Pf Pf Pf(I/O)
Pf Pf Pf Pf
![Page 128: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/128.jpg)
• Other possible heuristics:
• Multi-queue hops due to huge bursts
• Exponential backoff to avoid queue hopping
• Dynamic queue creation for outliers
128
![Page 129: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/129.jpg)
Scheduler Evaluation
129
![Page 130: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/130.jpg)
• That is, how well does a given scheduling policy perform under different loads?
• Typically, with respect to scheduling metrics: wait time, turnaround, utilization, etc.
130
![Page 131: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/131.jpg)
• Note: numerical metrics (e.g., wait time) are important, but may not tell the full story
• E.g., how, subjectively does a given scheduler “feel” under regular load?
131
![Page 132: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/132.jpg)
1. Paper & pencil computations
2. Simulations with synthetic or real-world job traces
3. Mathematical models; e.g., queueing theory
4. Real world testing (e.g., production OS’s)
132
![Page 133: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/133.jpg)
(Don’t worry, you’ll try your hand at all!)
133
![Page 134: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/134.jpg)
• E.g., UTSA process scheduling simulator
• Specify scheduling discipline and job details in configuration file
• Bursts can be defined discretely, or using probability distributions
134
![Page 135: Scheduling - bluesky.cs.iit.edubluesky.cs.iit.edu/cs450/slides/03-Scheduling.pdf · • Scheduling policy is used to select the next running ... BONUS SLIDE 16. ... Round Robin, q](https://reader031.vdocuments.pub/reader031/viewer/2022022005/5abb3ed47f8b9a8f058c44ac/html5/thumbnails/135.jpg)
135
SJF vs. PSJF vs. RR, q = 10 vs. RR, q = 20Processes: uniform bursts ≤ 20, CST = 1.0
Which one is which?