0 / 17
A process has five states
A process goes New → Ready → Running → Terminated. If it has to wait for I/O while running, it moves to Waiting and then comes back to Ready.
This example shows three processes, P1, P2 and P3, sharing a single CPU. With one CPU, only one process can be in Running at a time.
Press Next to go one step at a time, or Play on the right to watch in order. You can also use the ← → keys.
1 / 17
Process P1 has just been created. A program was launched and P1 came into being, but it has not joined the line for the CPU yet.
2 / 17
The OS accepts process P1. P1 now stands in the line waiting for the CPU (the ready queue) and waits its turn.
3 / 17
P1Ready → Running
Dispatch The CPU is free, so process P1 gets it right away and starts running.
4 / 17
Process P2 has been created too. Like P1, it has not joined the line yet.
5 / 17
Process P2 joins the line as well. But P1 is using the CPU, so P2 has to wait its turn.
6 / 17
Process P1's CPU time is up. So that no single process holds the CPU too long, P1 gives it up and goes to the back of the line.
7 / 17
P2Ready → Running
Dispatch Process P2, at the front of the line, gets the CPU and starts running.
8 / 17
Process P2 asks to read a file. There is nothing it can do until the read is done, so it gives up the CPU and waits in Waiting.
9 / 17
P1Ready → Running
Dispatch The CPU is free, so process P1, waiting in line, gets it again and continues from where it stopped.
10 / 17
Process P3 has been created.
11 / 17
Process P3 joins the line and waits its turn.
12 / 17
Process P2's file read is done. But P1 is using the CPU right now, so P2 cannot run yet and goes to the back of the line again.
13 / 17
P1Running → Terminated
Exit Process P1 finishes all its work and terminates. The CPU is now free.
14 / 17
P3Ready → Running
Dispatch Process P3, at the front of the line, gets the CPU and runs.
15 / 17
P3Running → Terminated
Exit Process P3 finishes all its work and terminates too.
16 / 17
P2Ready → Running
Dispatch Process P2, the last one left, gets the CPU and finishes the rest of its work with the file it read.
17 / 17
P2Running → Terminated
Exit Process P2 terminates as well, so all three processes are done.