(Notes by Thomas Lively)
AddressSanitizer is pushed! Hook up your allocators.
There is a chickadee file system! Read the docs.
There will be one more pset. It will be threads.
If you're up to date you'll be able to do a project as well!
Goal: Divide resources fairly among jobs
- jobs = processes
- fairness = equal time (for now)
Is round robin fair? No because blocking processes lose part of their time slices and are forever disadvantaged.
Strict priority: job with highest priority always runs.
- Starvation is a problem
- Priority inversion: low priority job locks resource so high priority job has to wait
Weighted fair sharing
- Jobs have priorities
- Jobs A and B with priorities Pa and Pb => A runs Pa/Pb times as
frequently as B
Can use lottery scheduling
N jobs, weights w1...wn
T = sum(w) pick a random R in [0, T) for i in [1, n]: if R < wi: return i else: R -= wi
This algo is O(n). Use an array of length T full of pids to make it O(1).
Can use stride scheduling
Each process gets stride si = 1/wi, ticket Ti
- Pick the process with minimum Ti
- Run it
- Ti = Ti + Si
Use circular arithmetic to make overflow a non-issue
Weighted fair sharing does not handle low latency jobs
- media playback (audio/video)
- need frequent short access to CPU on a deadline
- fuel injection (and other physical things)
When deadlines are missed there are Problems(TM)
BVT: “Borrowed-Virtual-Time (BVT) scheduling: Supporting latency-sensitive threads in a general-purpose scheduler.” Kenneth J. Duda and David R. Cheriton. In Proc. SOSP 1999. Link
Systems need to run a larger and more diverse set of applications, from real-time to interactive to batch, on uniprocessor and multiprocessor platforms. However, most schedulers either do not address latency requirements or are specialized to complex real-time paradigms, limiting their applicability to general-purpose systems.
In this paper, we present Borrowed-Virtual-Time (BVT) Scheduling, showing that it provides low-latency for realtime and interactive applications yet weighted sharing of the CPU across applications according to system policy, even with thread failure at the real-time level, all with a low-overhead implementation on multiprocessors as well as uniprocessors. It makes minimal demands on application developers, and can be used with a reservation or admission control module for hard real-time applications.
[The BVT scheduling paper!] Stride (WFS) + low latency support
Effective ticket for process i:
Ei = Ti - (warp ? Wi : 0)
When a blocked process unblocks:
Ti = max(Ti, min(runnable Tis))
By subtracting a little bit from Ti, we reward sleeping
warp is 0 for throughput jobs, >0 for latency jobs