Operating systems · interactive
CPU scheduling
One core, four programs that want it. The scheduler decides who runs next, and that choice changes how long each one waits, even though the total work is identical.
The core over time (0–23)
P1P2P3P4
| process | arrives | needs | done at | waited |
|---|---|---|---|---|
| P1 | 0 | 8 | 8 | 0 |
| P2 | 1 | 4 | 12 | 7 |
| P3 | 2 | 9 | 21 | 10 |
| P4 | 3 | 2 | 23 | 18 |
Average wait 8.75 · average turnaround 14.50 · context switches 3
First come, first served: average wait 8.75 time units.
Policy
1 Simple and fair in order of arrival. A long job at the front makes everyone behind it wait.
avg wait 8.75
2 3 4
In production
Tools and technologies
Every OS has a scheduler; you mostly influence it through priorities and limits.
Not tied to one language — use these names when you search docs or design a system.