CSE 451
Operating Systems
L14 - Scheduling - 2
Slides by: Tom Anderson
Baris Kasikci
How can we improve round-robin? Multi-level Feedback Queue (MFQ)
MFQ
MFQ
Example: Workload with I/O and Compute Tasks (Multilevel Feedback Queues)
Tasks
I/O Bound
CPU Bound 1
CPU Bound 2
Time
I/O start
I/O ends
I/O end
I/O start
Example: Workload with I/O and Compute Tasks (Multilevel Feedback Queues)
Tasks
I/O Bound
CPU Bound 1
CPU Bound 2
Time
I/O start
I/O ends
I/O end
I/O start
Example: Workload with I/O and Compute Tasks (Multilevel Feedback Queues)
Tasks
I/O Bound
CPU Bound 1
CPU Bound 2
Time
I/O start
I/O ends
I/O end
I/O start
Time slice
Drop priority
Example: Workload with I/O and Compute Tasks (Multilevel Feedback Queues)
Tasks
I/O Bound
CPU Bound 1
CPU Bound 2
Time
I/O start
I/O ends
I/O end
I/O start
Time slice
Drop priority
Example: Workload with I/O and Compute Tasks (Multilevel Feedback Queues)
Tasks
I/O Bound
CPU Bound 1
CPU Bound 2
Time
I/O start
I/O ends
I/O end
I/O start
Time slice
Drop priority
Preemption
Example: Workload with I/O and Compute Tasks (Multilevel Feedback Queues)
Tasks
I/O Bound
CPU Bound 1
CPU Bound 2
Time
I/O start
I/O ends
I/O end
I/O start
Time slice
Drop priority
Preemption
CPU Bound 1 continues here, because its time-slice was extended
Example: Workload with I/O and Compute Tasks (Multilevel Feedback Queues)
Tasks
I/O Bound
CPU Bound 1
CPU Bound 2
Time
I/O start
I/O ends
I/O end
I/O start
Time slice
Drop priority
Preemption
Example: Workload with I/O and Compute Tasks (Multilevel Feedback Queues)
Tasks
I/O Bound
CPU Bound 1
CPU Bound 2
Time
I/O start
I/O ends
I/O end
I/O start
Time slice
Drop priority
Preemption
Preemption
MFQ Downside Example: Multilevel Feedback Queues and Starvation
Tasks
I/O Bound - 1
I/O Bound - 2
I/O Bound - 3
I/O Bound - 4
I/O Bound - 5
CPU Bound - At low priority
Starvation - bump to higher priority level
At the limit, the CPU-bound task should get close to 1/6th of the CPU
I/O start
I/O ends
I/O end
I/O start
How to allocate resources in a principled way? -> Max-Min Fairness
Fair Queuing: Max-Min Fairness
Example: Workload with I/O and Compute Tasks
Tasks
I/O Bound
CPU Bound
CPU Bound
Time
Issues
I/O Request
I/O
Completes
Issues
I/O Request
Example: Workload with I/O and Compute Tasks
Tasks
I/O Bound
CPU Bound
CPU Bound
Time
Issues
I/O Request
I/O
Completes
Issues
I/O Request
I/O
Completes
Issues I/O Request
I/O
Completes
Weighted Fair Queueing
Give latency sensitive
tasks extra weight
Example:
A
B
C
A weight: 0.5
B: 0.25
C: 0.25
Uniprocessor Summary (1)
Uniprocessor Summary (2)
Multiprocessor Scheduling
Per-Processor Affinity Scheduling
Per-Processor Multi-level Feedback with Affinity Scheduling
Need rebalancing in case CPU 1 has a lot of high priority tasks
Lock
Lock
Lock
Bulk Synchronous Model of Parallelism
Bulk Synchronous in Action
CPUs do uneven work -> stragglers; everyone waits as the barrier; slowest thread determines progress
Scheduling Parallel Programs
Parallel Program Speedup
Little to no overhead to running in parallel, all cpus used
Some Overhead, some cpus underused
Can make use of additional cpus, but only up to a point (lock contention, tail latency)
Midterm Feedback