What are the states of a process in its life cycle?
A process moves through new, ready, running, waiting (blocked) and terminated. The scheduler moves it between ready and running; I/O or events move it between running and waiting.
Explain it simply
Think of a queue at an IRCTC ticket counter. You arrive and get a token (new). You wait in line (ready). The clerk serves you (running). If the clerk needs a document from you, you step aside until you fetch it (waiting). When you leave with your ticket, you are done (terminated).
Precisely, the five states are:
- New: the OS is creating the process and its control block.
- Ready: it has everything except the CPU and sits in the ready queue.
- Running: its instructions are executing on a CPU core.
- Waiting (blocked): it is paused for an event such as disk I/O or a keyboard press.
- Terminated: it has finished, and the OS is cleaning up.
Example
The transitions worth knowing:
new -> ready admitted by the long-term scheduler
ready -> running dispatcher picks it
running -> ready time slice expired or a higher-priority process arrived
running -> waiting it asked for I/O or waits on an event
waiting -> ready the I/O finished (never straight to running)
running -> terminated it called exit or was killedA single-core machine has at most one process in the running state. Every other live process is ready or waiting.
What to say in the interview
"A process has five states: new, ready, running, waiting and terminated. Only the scheduler moves a process from ready to running, and a blocked process returns to ready, not running, when its event completes."
Common mistakes
- Saying a waiting process goes directly back to running. It must rejoin the ready queue first.
- Mixing up "waiting" (blocked on an event) with "ready" (waiting only for the CPU).