PCB A · statePCB B · stateCPUAB
Blocks A and B: two processes, sitting in their current stateReady queue, CPU, blocked bench and Done tray: where a process can beEnvelope, done disc and timer tick: the events that move a processAt the back, the kernel's PCB state for each process and the Done tray. In the middle, the CPU and the timer. In front, the ready queue, the blocked bench and the disk. Process A runs, blocks on a disk read and lets B run; the disk wakes A to ready; the timer preempts B; A and then B finish. Each block sits in the state it is in. A tick here is a made-up unit of time to keep the numbers small. Real systems set the timer to interrupt every few milliseconds, and a disk read takes far longer than a time slice.

Three states

  1. A process is a running program. At any moment it is in exactly one of three states: running (on the CPU now), ready (could run, but waits for the CPU) or blocked (waits for something else, such as the disk).

Waiting for the disk

The timer and the end

What happens

;; step 1/10 · states
state     meaning                          can it use the CPU?
running   its instructions run on the CPU  it is using it
ready     it could run right now           yes, when picked
blocked   it waits for an event (disk ...) no, not until the event

one CPU runs one process at a time,
so all the others are ready or blocked.

A tick here is a made-up unit of time to keep the numbers small. Real systems set the timer to interrupt every few milliseconds, and a disk read takes far longer than a time slice. Systems use other names for the same states. xv6 calls them RUNNING, RUNNABLE and SLEEPING. Linux ps shows R for both running and ready (runnable, on the run queue) and S or D for sleeping, its word for blocked.