Start here
Process states (conceptual model)
A runnable process wants CPU time but may not be on a core yet. Running means currently executing on some CPU. Waiting (blocked) means it cannot proceed until an event, disk read, lock, child exit, completes.Terminated/zombie means execution stopped but the kernel retains a minimal record until a parent reaps status.
By the end of this page you should be able to
- Draw ready ↔ running ↔ waiting transitions and name typical triggers.
- Contrast interruptible vs uninterruptible sleep at a user-visible level.
- Explain why a zombie still appears in `ps` output.
Linux reality check
D (uninterruptible sleep) show up in top: often I/O or NFS, not “extra CPU work.”Operating systems · Processes
Process states and lifecycle
New, ready, running, waiting, terminated
TL;DR
Processes move between states driven by scheduler decisions and I/O: runnable threads sit on a runqueue; blocking syscalls move tasks to wait queues; termination leaves a zombie until reaped, diagrams must include wait queues, not just “running.”
Summary
State diagrams are bookkeeping for concurrency: they tell you which queues to inspect when debugging latency (scheduler runqueue vs device waitqueue vs lock wait).
Diagram
Read the diagram definition
stateDiagram-v2
[*] --> New
New --> Ready: admitted
Ready --> Running: scheduled
Running --> Ready: preempted
Running --> Waiting: block
Waiting --> Ready: wakeup
Running --> Terminated: exitDeeper narrative
Five-state models are pedagogical; Linux exposes finer states (`TASK_KILLABLE`, `D` uninterruptible sleep). Transitions are driven by syscalls, signals, scheduler decisions, and interrupt bottom halves, profiling “high system time” often maps to state thrashing.
Mechanism (step by step)
New → admitted
Admission policy may limit runnable children to prevent fork bombs.
Ready ↔ running
Timer tick and wakeups move tasks between runqueue and CPU.
Waiting
Interruptible waits can return `-EINTR`; uninterruptible waits ignore non-fatal signals (classic `D` state).
Terminated/zombie
Resources released except PCB slot until parent `wait`s.
Key insights
Two orthogonal “waiting” reasons
Wakeups are explicit
State is per-task
Load average encodes runnable + uninterruptible
Did you know?
Common pitfalls
Spinning on `sched_yield`
Burns CPU; use proper blocking primitives or back-off.
Misreading `top` state
`S` vs `D` vs `R`: D often means NFS/disk driver wait, not CPU work.
Comparison
Classic 5-state model (names vary)
| State | Meaning |
|---|---|
| New | Being created |
| Ready | Runnable, waiting for CPU |
| Running | Executing on a CPU |
| Waiting | Blocked for I/O or synchronization |
| Terminated | Zombie until reaped or exiting kernel bookkeeping |
Glossary
Runnable
Interruptible sleep
Zombie
Interview follow-ups
- Why might a process stay in D state indefinitely?
- What transition occurs when `read` blocks on an empty pipe?
- How does cgroup freezer differ from SIGSTOP?
Callouts
Ops reality
A flood of `D` states often indicates NFS, broken storage, or driver bugs, not CPU saturation.
Walkthrough & deep dive
Left: practical “how would I use this?” threads. Right: slower, code-leaning explanations, open one panel at a time so the page does not feel like a wall of sameness.
Walkthrough
Trace a blocking read
Deep dive
Linux `ps` codes
`R S D T Z` etc. learn what each implies for killability and debugging steps.
Watch states
watch -n0.5 'ps -o pid,stat,cmd -p $PID'
Self-check
1A process in READY is waiting for…
2Zombie means…
3Uninterruptible sleep often indicates…