schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies &...
TRANSCRIPT
![Page 2: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/2.jpg)
Computer ScienceScience
§Overview
2
![Page 3: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/3.jpg)
Computer ScienceScience
scheduling: policies & mechanisms used to allocate a resource to some set of entities
3
![Page 4: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/4.jpg)
Computer ScienceScience
resource & entities: CPU & processes
other possibilities:
- resources: memory, I/O bus/devices
- entities: threads, users, groups
4
![Page 5: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/5.jpg)
Computer ScienceScience
policy: high-level “what”
- aka scheduling disciplines
mechanism: low-level “how”
- e.g., interrupts, context switch
5
![Page 6: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/6.jpg)
Computer ScienceScience
(we’ll start with policy first)
6
![Page 7: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/7.jpg)
Computer ScienceScience
essential 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: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/8.jpg)
Computer ScienceScience
at a high level (policy), only concern ourselves with macro process state
one of running, ready, or blocked
8
![Page 9: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/9.jpg)
Computer ScienceScience
running = consuming CPU
ready = “runnable”, but not running
blocked = not runnable (e.g., waiting for I/O)
9
![Page 10: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/10.jpg)
Computer ScienceScience
Ready
Running
Blocked
I/O request(trap/syscall)
scheduled
I/O completion
creation
completion
Ready Blocked
swap in/out swap in/out
preemption
10
![Page 11: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/11.jpg)
Computer ScienceScience
preemptive scheduling
☑ running → ready transition
11
![Page 12: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/12.jpg)
Computer ScienceScience
non-preemptive scheduling
☒ running → ready transition
i.e., not = batch!
12
![Page 13: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/13.jpg)
Computer ScienceScience
domain of the “swapper” — separate from the CPU scheduler
- frequency in seconds vs. ms
- ignore for now
Ready Blocked
swap in/out swap in/out
13
![Page 14: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/14.jpg)
Computer ScienceScience
Ready
Runningscheduled
convenient to envision a ready queue/set
scheduling policy is used to select the next running process from the ready queue
14
![Page 15: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/15.jpg)
Computer ScienceScience
policies vary by:
1. preemptive vs. non-preemptive
2. factors used in selecting a process
3. goals; i.e., why are we selecting a given process?
15
![Page 16: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/16.jpg)
Computer ScienceScience
scheduling goals are usually predicated on optimizing certain scheduling metrics
— can be provable or based on heuristics
16
![Page 17: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/17.jpg)
Computer ScienceScience
§Scheduling Metrics
17
![Page 18: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/18.jpg)
Computer ScienceScience
metrics we’ll be concerned with:
- turnaround time
- wait time
- response time
- throughput
- utilization
18
![Page 19: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/19.jpg)
Computer ScienceScience
turnaround time:
Tturnaround = Tcompletion - Tcreation
i.e., total time to complete process
19
![Page 20: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/20.jpg)
Computer ScienceScience
turnaround time depends on much more than the scheduling discipline!
- process runtime
- process I/O processing time
- how many CPUs available
- how many other processes need to run
20
![Page 21: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/21.jpg)
Computer ScienceScience
wait time: time spent in ready queue
i.e., how long does the scheduler force a runnable process to wait for a CPU
- better gauge of scheduler’s effectiveness
21
![Page 22: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/22.jpg)
Computer ScienceScience
turnaround & wait time are measured over the course of an entire process — sometimes refer to as the “job”
- not a very useful metric for interactive processes
- which typically alternate between CPU & I/O bursts, indefinitely
22
![Page 23: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/23.jpg)
Computer ScienceScience
5.4 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Feb 2, 2005
Alternating Sequence of CPU And I/O BurstsAlternating Sequence of CPU And I/O Bursts
“bursty” execution
23
![Page 24: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/24.jpg)
Computer ScienceScience
5.5 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Feb 2, 2005
Histogram of CPUHistogram of CPU--burst Timesburst Times
burst length histogram
24
![Page 25: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/25.jpg)
Computer ScienceScience
can take measurements per-burst
i.e., from first entry into ready queue to completion or transition to blocked
- burst turnaround time, aka response time
- burst wait time
25
![Page 26: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/26.jpg)
Computer ScienceScience
throughput:
number of completed jobs or bursts per time unit (e.g., N/sec)
26
![Page 27: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/27.jpg)
Computer ScienceScience
utilization:
% of time CPU is busy running jobs
- note: CPU can be idle if there are no active jobs or if all jobs are blocked!
27
![Page 28: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/28.jpg)
Computer ScienceScience
another (subjective) metric: fairness
- what does this mean?
- how to measure it?
- is it useful?
28
![Page 29: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/29.jpg)
Computer ScienceScience
§Scheduling Policies
29
![Page 30: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/30.jpg)
Computer ScienceScience
1. First Come First Served
30
![Page 31: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/31.jpg)
Computer ScienceScience
Process Arrival Time Burst Time
P1 0 24
P2 0 3
P3 0 3
Wait times: P1 = 0, P2 = 24, P3 = 27Average: (0+24+27)/3 = 17
P1 P2 P3
24 27 300 “Gantt chart”
31
![Page 32: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/32.jpg)
Convoy Effect32
![Page 33: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/33.jpg)
Computer ScienceScience
Process Arrival Time Burst Time
P3 0 3
P2 0 3
P1 0 24
P3 P2 P1
3 6 300
Wait times: P1 = 6, P2 = 3, P3 = 0Average: (6+3+0)/3 = 3
33
![Page 34: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/34.jpg)
Computer ScienceScience
2. Shortest Job First
34
![Page 35: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/35.jpg)
Computer ScienceScience
0
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
P2 waits
P3 waits
P4 waits
P1 P3 P2 P4
Non-preemptive SJF
35
![Page 36: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/36.jpg)
Computer ScienceScience
Wait times:P1 = 0, P2 = 6, P3 = 3, P4=7Average: (0+6+3+7)/4 = 4
P2 waits
P3 waits
P4 waits
P1 P3 P2 P4
0
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
36
![Page 37: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/37.jpg)
Computer ScienceScience
can we do better?
37
![Page 38: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/38.jpg)
Computer ScienceScience
Yes! (theoretically): Preemptive SJF
a.k.a. Shortest-Remaining-Time-First
38
![Page 39: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/39.jpg)
Computer ScienceScience
P1 P3 P4
0
P2 P2 P1
P1 waits
P2 waits
P4 waits
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
39
![Page 40: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/40.jpg)
Computer ScienceScience
P1 P3 P4
0
P2 P2 P1
P1 waits
P2 waits
P4 waits
Wait times: P1 = 9, P2 = 1, P3 = 0, P4 = 2Average: (9+1+0+2)/4 = 3
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
40
![Page 41: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/41.jpg)
Computer ScienceScience
SJF/SRTF are greedy algorithms;
i.e., they always select the local optima
greedy algorithms don’t always produce globally optimal results (e.g., hill-climbing)
41
![Page 42: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/42.jpg)
Computer ScienceScience
consider 4 jobs arriving at t=0, with burst lengths t0, t1, t2, t3
avg. wait time if scheduled in order?
=3t0 + 2t1 + t2
4
42
![Page 43: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/43.jpg)
Computer ScienceScience
— a weighted average; clearly minimized by running shortest jobs first.
I.e., SJF/PSJF are provably optimal w.r.t. wait time!
=3t0 + 2t1 + t2
4
43
![Page 44: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/44.jpg)
Computer ScienceScience
at what cost?
… potential starvation!
(possible for both non-preemptive & preemptive variants)
44
![Page 45: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/45.jpg)
Computer ScienceScience
also, we’ve been making two simplifying assumptions:
1. context switch time = 0
2. burst lengths are known in advance
45
![Page 46: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/46.jpg)
Computer ScienceScience
(1) will be dealt with later;
(2) is a serious problem!
46
![Page 47: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/47.jpg)
Computer ScienceScience
typically predict future burst lengths based on past job behavior
- simple moving average
- exponentially weighted moving average (EMA)
47
![Page 48: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/48.jpg)
Computer ScienceScience
Observed: ρn-1
Estimated: σn-1
Weight (α): 0 ≤ α ≤ 1
EMA: σn = α⋅ρn-1 + (1–α)⋅σn-1
48
![Page 49: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/49.jpg)
Actual Avg (3) Error EMA Error4 5.00 1.00 5.00 1.00 EMA Alpha:EMA Alpha: 0.25 4.00 1.00 4.80 0.205 4.50 0.50 4.84 0.166 4.67 1.33 4.87 1.1313 5.33 7.67 5.10 7.9012 8.00 4.00 6.68 5.3211 10.33 0.67 7.74 3.266 12.00 6.00 8.39 2.397 9.67 2.67 7.92 0.925 8.00 3.00 7.73 2.73
Avg err: 2.78 2.50
0
2.6
5.2
7.8
10.4
13.0
Actual Avg (3) EMA
49
![Page 50: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/50.jpg)
Computer ScienceScience
how to deal with starvation?
one way: enforce fairness
50
![Page 51: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/51.jpg)
Computer ScienceScience
3. Round Robin: the “fairest” of them all
- FIFO queue
- each job runs for max time quantum
- if unfinished, re-enter queue at back
51
![Page 52: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/52.jpg)
Computer ScienceScience
Given time quantum q and n jobs:
- max wait time = q ∙ (n – 1)
- each job receives 1/n timeshare
52
![Page 53: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/53.jpg)
Computer ScienceScience
P1 waits
P2 waits
P1 waits
P2 waits
P3 waits
P4 waits P4 waits
P1 P3
0
P2 P1 P4 P2 P1 P4
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
Round Robin, q=3
53
![Page 54: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/54.jpg)
Computer ScienceScience
P1 waits
P2 waits
P1 waits
P2 waits
P3 waits
P4 waits P4 waits
P1 P3
0
P2 P1 P4 P2 P1 P4
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
Wait times: P1 = 8, P2 = 8, P3 = 5, P4 = 7Average: (8+8+5+7)/4 = 7
54
![Page 55: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/55.jpg)
Computer ScienceScience
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
Avg. Turnaround Avg. 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
55
![Page 56: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/56.jpg)
Computer ScienceScience
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
Avg. Turnaround Avg. 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
(CST=1)
56
![Page 57: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/57.jpg)
Computer ScienceScience
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
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
(CST=1)
57
![Page 58: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/58.jpg)
Computer ScienceScience
q large ⇒ FIFO
q small ⇒ big CST overhead
58
![Page 59: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/59.jpg)
Computer ScienceScience
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
59
![Page 60: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/60.jpg)
Computer ScienceScience
RR permits CPU-hungry jobs to run periodically, but prevents them from monopolizing the system (compare to FCFS and SJF)
… but also introduces inflexible systemic overhead: constant context switching
60
![Page 61: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/61.jpg)
Computer ScienceScience
Fairness is overrated!
61
![Page 62: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/62.jpg)
Computer ScienceScience
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
62
![Page 63: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/63.jpg)
Computer ScienceScience
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
63
![Page 64: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/64.jpg)
Computer ScienceScience
Recall: SJF is prone to starvation
Common issue for priority schedulers
- combat with priority aging
64
![Page 65: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/65.jpg)
Computer ScienceScience
4. Highest Penalty Ratio Next
- example of a priority scheduler that uses aging to avoid starvation
65
![Page 66: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/66.jpg)
Computer ScienceScience
Two statistics maintained for each job:
1. total CPU execution time, t
2. “wall clock” age, T
66
![Page 67: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/67.jpg)
Computer ScienceScience
Priority, “penalty ratio” = T / t
- ∞ when job is first ready
- decreases as job receives CPU time
67
![Page 68: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/68.jpg)
Computer ScienceScience
HPRN in practice would incur too many context switches (due to very short bursts)
— likely institute minimum burst quanta
68
![Page 69: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/69.jpg)
Computer ScienceScience
5. Selfish RR
- example of a more sophisticated priority based scheduling policy
69
![Page 70: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/70.jpg)
Computer ScienceScience
priority ↑ α
priority ↑ β
β = 0 : RR
β ≥ (α ≠ 0) : FCFS
β > (α = 0) : RR in batches
α > β > 0 : “Selfish” (ageist) RR
active (RR)CPU
holdingarriving
70
![Page 71: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/71.jpg)
Computer ScienceScience
Another problem (on top of starvation) possibly created by priority-based scheduling policies: priority inversion
71
![Page 72: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/72.jpg)
Computer ScienceScience
Process Priority StateP1 High ReadyP2 Mid ReadyP3 Mid ReadyP4 Low Ready
72
![Page 73: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/73.jpg)
Computer ScienceScience
requestall
ocate
d
Process Priority StateP1 High RunningP2 Mid ReadyP3 Mid ReadyP4 Low Ready
Resource
P1 P2 P4P3
73
![Page 74: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/74.jpg)
Computer ScienceScience
Process Priority StateP1 High BlockedP2 Mid ReadyP3 Mid ReadyP4 Low Ready
request
P1 P2 P4
Resource
P3
alloc
ated
(mutually exclusive allocation)
74
![Page 75: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/75.jpg)
Computer ScienceScience
Process Priority StateP1 High BlockedP2 Mid RunningP3 Mid ReadyP4 Low Ready
request
P1 P2 P4
Resource
P3
alloc
ated
(mutually exclusive allocation)
75
![Page 76: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/76.jpg)
Computer ScienceScience
request
P1 P4
Resource
P3
alloc
ated
Process Priority StateP1 High BlockedP2 Mid DoneP3 Mid RunningP4 Low Ready
(mutually exclusive allocation)
76
![Page 77: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/77.jpg)
Computer ScienceScience
request
P1 P4
Resourceall
ocate
d
Process Priority StateP1 High BlockedP2 Mid DoneP3 Mid DoneP4 Low Running
(mutually exclusive allocation)
77
![Page 78: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/78.jpg)
Computer ScienceScience
request
P1
Resource
Process Priority StateP1 High BlockedP2 Mid DoneP3 Mid DoneP4 Low Done
(mutually exclusive allocation)
78
![Page 79: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/79.jpg)
Computer ScienceScience
P1
Resourceallocated
Process Priority StateP1 High ReadyP2 Mid DoneP3 Mid DoneP4 Low Done
(mutually exclusive allocation)
79
![Page 80: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/80.jpg)
Computer ScienceScience
P1
Resourceallocated
(mutually exclusive allocation)
Process Priority StateP1 High RunningP2 Mid DoneP3 Mid DoneP4 Low Done
80
![Page 81: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/81.jpg)
Computer ScienceScience
priority inversion: a high priority job effectively takes on the priority of a lower-level one that holds a required resource
81
![Page 82: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/82.jpg)
Computer ScienceScience
high profile case study: NASA Pathfinder
- spacecraft developed a recurring system failure/reset
- occurred after deploying data-gathering robot to surface of Mars
82
![Page 83: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/83.jpg)
Computer ScienceScience
culprits:
- flood of meteorological data
- low priority of related job: ASI/MET
- a shared, mutually exclusive resource (semaphore guarding an IPC pipe)
83
![Page 84: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/84.jpg)
Computer ScienceScience
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
84
![Page 85: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/85.jpg)
Computer ScienceScience
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
85
![Page 86: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/86.jpg)
Computer ScienceScience
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
86
![Page 87: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/87.jpg)
Computer ScienceScience
how?
- enabling priority inheritance via semaphores (in vxWorks OS)
- (why wasn’t it on by default?)
- prescient remote (!) tracing & patching facilities built in to system
87
![Page 88: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/88.jpg)
Computer ScienceScience
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
88
![Page 89: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/89.jpg)
Computer ScienceScience
takeaways:
- scheduling bugs are hard to predict, track down, and fix
- priority inheritance provides a “solution” for priority inversion
- scheduling is rocket science!
89
![Page 90: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/90.jpg)
Computer ScienceScience
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?
90
![Page 91: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/91.jpg)
Computer ScienceScience
Even with the 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
91
![Page 92: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/92.jpg)
Computer ScienceScience
6. Multi-Level Queue (MLQ)
- disjoint ready queues
- separate schedulers/policies for each
92
![Page 93: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/93.jpg)
Computer ScienceScience
Fixed priority
RR (small q)
FCFS
RR (larger q)
system
interactive
batch
normal
93
![Page 94: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/94.jpg)
Computer ScienceScience
requires queue arbitration strategy in place
94
![Page 95: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/95.jpg)
Computer ScienceScience
Fixed priority
RR (small q)
FCFS
RR (larger q)
system
interactive
batch
normal
decr
easi
ng p
rior
ityapproach 1: prioritize top, non-empty queue
95
![Page 96: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/96.jpg)
Computer ScienceScience
Fixed priority
RR (small q)
FCFS
RR (larger q)
system
interactive
batch
normal
approach 2: aggregate time slices
30%
15%
50%
5%
96
![Page 97: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/97.jpg)
Computer ScienceScience
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
97
![Page 98: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/98.jpg)
Computer ScienceScience
classification issue: what if process characteristics change dynamically?
- e.g., photo editor: tool selection (interactive) ➞ apply filter (CPU hungry) ➞ simple edits (interactive)
98
![Page 99: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/99.jpg)
Computer ScienceScience
7. Multi-Level Feedback Queue
- supports movement between queues after initial assignment
- based on ongoing job accounting
99
![Page 100: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/100.jpg)
Computer ScienceScience
RR (q=2)
RR (q=8)
RR (q=4)
e.g., 3 RR queues with different q
assignment based on q/burst-length fit
100
![Page 101: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/101.jpg)
Computer ScienceScience
RR (q=2)
RR (q=4)
RR (q=8)
0
P1
P1
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
101
![Page 102: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/102.jpg)
Computer ScienceScience
RR (q=2)
P1 RR (q=4)
RR (q=8)
P1
0
P2
P2
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
102
![Page 103: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/103.jpg)
Computer ScienceScience
RR (q=2)
P2 P1 RR (q=4)
RR (q=8)
P1
0
P2
P3
P3
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
103
![Page 104: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/104.jpg)
Computer ScienceScience
RR (q=2)
P2 P1 RR (q=4)
RR (q=8)
P1 P3
0
P2
P4
P4
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
104
![Page 105: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/105.jpg)
Computer ScienceScience
RR (q=2)
P4 P2 P1 RR (q=4)
RR (q=8)
P1 P3
0
P2 P4 P1
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
105
![Page 106: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/106.jpg)
Computer ScienceScience
RR (q=2)
P4 P2 RR (q=4)
P1 RR (q=8)
P1 P3
0
P2 P4 P1 P2
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
106
![Page 107: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/107.jpg)
Computer ScienceScience
RR (q=2)
P4 RR (q=4)
P1 RR (q=8)
P1 P3
0
P2 P4 P1 P2 P4
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
107
![Page 108: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/108.jpg)
Computer ScienceScience
RR (q=2)
RR (q=4)
P1 RR (q=8)
P1 P3
0
P2 P4 P1 P2 P4 P1
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
108
![Page 109: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/109.jpg)
Computer ScienceScience
P1 P3
0
P2 P4 P1 P2 P4 P1
Wait times: P1 = 9, P2 = 7, P3 = 0, P4 = 6Average: (9+7+0+6)/4 = 5.5 (vs 7 for RR, q=3)
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
109
![Page 110: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/110.jpg)
Computer ScienceScience
- following I/O, processes return to previously assigned queue
- when to move up?
- for RR, when burst ≤ q
110
![Page 111: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/111.jpg)
Computer ScienceScience
RR (q=2)
RR (q=4)
RR (q=8)
0
e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)
111
![Page 112: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/112.jpg)
Computer ScienceScience
RR (q=2)
RR (q=4)
RR (q=8)
0
e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)
Pf
Pf
112
![Page 113: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/113.jpg)
Computer ScienceScience
RR (q=2)
RR (q=4)
RR (q=8)
0
Pf
Pf Pf
e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)
113
![Page 114: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/114.jpg)
Computer ScienceScience
RR (q=2)
RR (q=4)
RR (q=8)
0
Pf Pf
Pf
Pf
e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)
114
![Page 115: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/115.jpg)
Computer ScienceScience
RR (q=2)
RR (q=4)
RR (q=8)
0
Pf
Pf Pf Pf
(I/O)
e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)
115
![Page 116: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/116.jpg)
Computer ScienceScience
RR (q=2)
RR (q=4)
RR (q=8)
0
Pf Pf Pf
(I/O)
e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)
116
![Page 117: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/117.jpg)
Computer ScienceScience
RR (q=2)
RR (q=4)
RR (q=8)
0
Pf Pf Pf
(I/O)
Pf
Pf
e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)
117
![Page 118: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/118.jpg)
Computer ScienceScience
RR (q=2)
RR (q=4)
RR (q=8)
0
Pf Pf Pf
(I/O)
Pf
Pf
e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)
118
![Page 119: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/119.jpg)
Computer ScienceScience
RR (q=2)
RR (q=4)
RR (q=8)
0
Pf Pf Pf
(I/O)
Pf
e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)
119
![Page 120: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/120.jpg)
Computer ScienceScience
RR (q=2)
RR (q=4)
RR (q=8)
0
Pf Pf Pf
(I/O)
Pf
Pf
Pf
e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)
120
![Page 121: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/121.jpg)
Computer ScienceScience
RR (q=2)
RR (q=4)
RR (q=8)
0
Pf Pf Pf
(I/O)
Pf
Pf
Pf
e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)
121
![Page 122: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/122.jpg)
Computer ScienceScience
RR (q=2)
RR (q=4)
RR (q=8)
0
Pf Pf Pf
(I/O)
Pf Pf
e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)
122
![Page 123: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/123.jpg)
Computer ScienceScience
RR (q=2)
RR (q=4)
RR (q=8)
0
Pf Pf Pf
(I/O)
Pf Pf
Pf
Pf
e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)
123
![Page 124: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/124.jpg)
Computer ScienceScience
RR (q=2)
RR (q=4)
RR (q=8)
0
Pf Pf Pf
(I/O)
Pf Pf
Pf
Pf Pf
e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)
124
![Page 125: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/125.jpg)
Computer ScienceScience
RR (q=2)
RR (q=4)
RR (q=8)
0
Pf Pf Pf
(I/O)
Pf Pf Pf Pf
e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)
125
![Page 126: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/126.jpg)
Computer ScienceScience
other possible heuristics:
- multi-queue hops due to huge bursts
- exponential backoff to avoid queue hopping
- dynamic queue creation for outliers
126
![Page 127: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/127.jpg)
Computer ScienceScience
§Scheduler Evaluation
127
![Page 128: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/128.jpg)
Computer ScienceScience
i.e., how well does a given scheduling policy perform under different loads?
typically, w.r.t. scheduling metrics: wait time, turnaround, utilization, etc.
128
![Page 129: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/129.jpg)
Computer ScienceScience
n.b., 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?
129
![Page 130: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/130.jpg)
Computer ScienceScience
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 OSes)
130
![Page 131: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/131.jpg)
Computer ScienceScience
(never fear, you’ll try your hand at all!)
131
![Page 132: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/132.jpg)
Computer ScienceScience
e.g., UTSA process scheduling simulator
- specify scheduling discipline and job details in configuration file
- bursts can be defined discretely, or using probability distributions
132
![Page 133: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/133.jpg)
Computer ScienceScience
output: Gantt charts & metrics
133
![Page 134: Schedulingchinetti.me/classes/cs450/lee-site/assets/slides-sched.pdfscheduling: policies & mechanisms used to allocate a resource to some set of entities 3. Computer Science Science](https://reader033.vdocument.in/reader033/viewer/2022043000/5f741dcbf31dbf035c0a7ae2/html5/thumbnails/134.jpg)
Computer ScienceScience
SJF vs. PSJF vs. RR, q=10 vs. RR, q=20processes: uniform bursts ≤ 20, CST = 1.0
Which is which?
134