Process state

Also known as: process lifecycle

On this page 8

Process state is the current stage of a process in its lifecycle, recorded by the kernel to show whether the program is executing on a CPU, waiting for a CPU or waiting for an event such as disk input. In operating systems, the state drives nearly every decision of the scheduler, because only processes in the right state can be chosen to run.

The sequence of states a program passes through from creation to removal is often called the process lifecycle. Every topic in processes & scheduling, from time slices to priority inversion, ultimately describes how and why processes move between these states.

How the kernel tracks process state

The kernel stores the state as a field inside the process control block, the per-process data structure that also holds registers, memory maps and open files. A state transition is simply an update of that field combined with moving the process between kernel queues, so the state and the queue membership always agree.

Ready processes sit in the run queue, while blocked processes sit in wait queues attached to the resource they need, such as a pipe, a lock or a disk request. When the resource becomes available, the kernel performs a wakeup, changes the state to ready and inserts the process into the run queue again.

On a machine with several cores, one running process per core is the upper limit at any instant. All other runnable processes wait in the ready state, which is why a system can show hundreds of processes while only a handful actually execute.

The classic five-state model

Textbooks describe process state with a five-state model that captures the essential behavior of every general-purpose kernel. The table lists each state, what the process is doing and where the kernel keeps it.

StateMeaningWhere the kernel keeps it
NewBeing created, resources still allocatedProcess table, not yet schedulable
ReadyAble to run, waiting for a CPURun queue
RunningExecuting instructions on a coreCurrent task of that core
BlockedWaiting for I/O or another eventWait queue of the resource
TerminatedFinished, awaiting final cleanupProcess table until reaped
States of the five-state process model

Some models add suspended ready and suspended blocked states for processes whose memory was swapped out entirely. Modern paging systems rarely swap whole processes, so these extra states now appear mostly in theory and in older designs.

Transitions between process states

A process changes state only through well-defined events, and each event is handled by a specific part of the kernel. Knowing the trigger of each transition explains most scheduling behavior.

TransitionTypical triggerKernel component involved
New to readyCreation completes after fork or spawnProcess creation code
Ready to runningScheduler dispatches the processScheduler and dispatcher
Running to readyTime slice expires or preemptionTimer interrupt handler
Running to blockedSystem call that must waitSystem call layer
Blocked to readyI/O completion or signalInterrupt or wakeup path
Running to terminatedExit call or fatal signalExit and cleanup code
Common state transitions and their triggers

A blocked process never moves directly to running. It must first become ready and then win the scheduler decision, which is why a process that just received its data may still wait a few milliseconds before it continues. In preemptive multitasking, the running-to-ready transition can happen at any instruction; in cooperative multitasking, it happens only when the process yields voluntarily.

Process states in real kernels

Production kernels refine the textbook model with more specific states that reveal why a process is waiting. Tools such as ps and top on Linux show these states as single-letter codes, and Windows exposes similar thread states through its performance tools.

CodeLinux stateTextbook equivalent
RRunning or runnableRunning or ready
SInterruptible sleepBlocked, wakes on signal
DUninterruptible sleepBlocked, ignores signals
TStopped by job control or debuggerSuspended
ZZombie, exited but not reapedTerminated
Linux process state codes and their meaning

Linux deliberately merges ready and running into one runnable state, because the difference changes every few milliseconds. Windows tracks state per thread rather than per process, with states such as Ready, Running, Waiting and Standby, which reflects the fact that the thread is the real unit of scheduling there.

Zombie and orphan processes

A zombie process has finished execution but keeps its process table entry until the parent process reads its exit status with a wait call. Zombies use almost no memory, but each one holds a process identifier, and a parent that never reaps its children can exhaust the PID space.

An orphan process is a child whose parent exited first. Unix-like systems reassign orphans to init or a designated subreaper, which reaps them automatically, so orphans are normal while accumulating zombies indicate a bug in the parent program.

Diagnosing problems with process state

Reading process states is one of the fastest diagnostic techniques for a slow or hung system. The distribution of states shows whether the bottleneck is the CPU, storage or application logic.

Observed patternLikely causeRecommended check
Many processes in RCPU saturationCompare load average with core count
Many processes in DSlow storage or stuck network file systemInspect I/O wait and device latency
Growing number of ZParent does not call waitFix child reaping in the parent
Process stuck in SWaiting on lock, socket or pipeTrace system calls and lock holders
Symptoms, likely causes and checks

A common misconception treats a high load average as pure CPU load. On Linux, the load average counts both runnable and uninterruptible processes, so a storage stall can raise it sharply while the CPU remains mostly idle. Another frequent mistake is trying to kill a process in state D: the signal is queued but takes effect only after the I/O completes.

Put simply

Think of a busy doctor’s office with a single doctor. One patient is inside the examination room, several patients sit in the waiting room, and a few others have gone to get a blood test and cannot see the doctor until the results come back.

A computer treats its programs the same way. The process state is simply a label saying which group each program belongs to right now: working on the processor, waiting its turn or waiting for something else to finish. The system uses these labels to decide who goes next, so the state is how the computer keeps order among many programs.

In practice

An administrator of a Linux build server notices that compilation jobs take twice as long as usual. The machine has 16 cores, and the load average shows about 40, which at first suggests the CPU is overloaded. Running top reveals a different picture: CPU usage sits near 30 percent, and roughly 25 compiler processes show state D.

The uninterruptible sleep points to storage, not computation. Further checks show that the shared network file system holding the source tree responds with latencies above 200 milliseconds after a switch failure. Once the network path is repaired, the D-state processes return to R, the load average falls below 16 and build times return to normal without adding any CPU capacity.