What CPU scheduling decides
When several processes are ready but only some cores are free, the OS short-term scheduler chooses which ready process runs next. A program is a stream of CPU bursts separated by I/O bursts; the scheduler only ever schedules the CPU bursts. A scheduler is non-preemptive if a process keeps the CPU until it finishes or voluntarily blocks (I/O or exit), and preemptive if the OS can forcibly take the CPU away (on a timer interrupt or the arrival of a higher-priority job).
The four time metrics
For a process with arrival time , first time it gets the CPU , completion time , and total CPU burst :
| Metric | Definition | Formula |
|---|---|---|
| Turnaround time | total time in the system | |
| Waiting time | time spent ready but not running | |
| Response time | until first CPU service | |
| Throughput | jobs finished per unit time |
Averages are taken over all processes, e.g. . Throughput and CPU utilization are system-wide; the rest are per-process.
The classic algorithms
| Algorithm | Preemptive? | Picks | Note |
|---|---|---|---|
| FCFS / FIFO | no | earliest arrival | simple; suffers the convoy effect |
| SJF | no | shortest next burst | optimal ; needs burst length |
| SRTF | yes | shortest remaining time | preemptive SJF |
| Priority | either | highest priority | risk of starvation (fix: aging) |
| Round Robin | yes | next in queue, quantum | fair; good response time |
| Rate Monotonic | yes | shortest period (real-time, fixed priority) | preempts lower-rate tasks |
SJF minimizes average waiting time among non-preemptive schedulers, but it requires knowing burst lengths in advance, so it is mostly a theoretical bound. Round Robin trades a little throughput for bounded response time: small improves responsiveness but adds context-switch overhead.
Mini-example (non-preemptive FCFS)
Three jobs arrive at in order with bursts .
FCFS runs , so waiting times are and . Reordering shortest-first (SJF) as gives waits and — the convoy effect that a long job at the front inflates everyone's wait.
Multicore throughput
With identical cores and total CPU work , the makespan (time to finish a batch) is bounded below by . This bound is achievable when each process's I/O wait can be perfectly overlapped by another process's CPU burst, keeping every core busy — then I/O time hides completely behind computation.
Exam trick: Watch the preemption word. "Strict-priority and non-preemptive" points to FCFS — Rate Monotonic is strict fixed-priority but preemptive, and SJF has a preemptive variant (SRTF), so both fail. For a multicore batch with a matched CPU/I/O ratio, the answer is just (total CPU work) / (number of cores), not the naive sum of all burst-plus-wait times.