It is ten in the morning at a bank's data centre. Tellers in forty branches are pressing Enter and expecting their screens to answer at once. A month-end report that will run for twenty minutes has been started in the background. A backup has just woken up. The server has sixteen cores, and every one of them is busy. Somebody, somewhere inside the operating system, is deciding every few milliseconds which job gets which core. Get that decision slightly wrong and a teller stares at a frozen screen while the report hogs the machine. Get it right and nobody notices that anything is being decided at all.
In the last lesson you learned the basic rules: first come first served, shortest job first, priority, and Round Robin. Those rules are enough to draw a chart for three processes in an exam. A real machine asks harder questions. How long should a slice be, and what does a wrong answer cost? What do you do when short interactive jobs and long batch jobs must share one CPU? What changes when there are eight CPUs instead of one? And what do you do when a late answer is a wrong answer, as with the brake controller of a car?
By the end of this chapter you will be able to count the context switches of a Round Robin run and work out what they cost, and to choose a quantum between two limits. You will run HRRN by hand, and trace a multilevel queue and a multilevel feedback queue, saying at each step which queue a process is in and why. You will explain how scheduling works on several CPUs, including processor affinity and load balancing. You will test whether a set of periodic tasks can meet its deadlines under rate-monotonic scheduling and under earliest-deadline-first, and draw the schedule. And you will be able to say, for any workload an exam describes, which policy fits and why.