Process control block

Also known as: PCB · task control block

On this page 8

A process control block (PCB) is the kernel data structure that represents one process in operating systems: it records the process identity, its state, the saved CPU registers, memory mappings, open resources and scheduling data. Also called a task control block, it is the single place where the kernel keeps everything needed to stop a process and later resume it exactly where it left off.

Within processes & scheduling, the PCB is the object that schedulers, interrupt handlers and system calls actually manipulate. A process exists, from the kernel’s point of view, only as long as its PCB exists, and every scheduling decision is ultimately a choice between PCBs waiting in queues.

What a process control block contains

A process control block groups several categories of information that the kernel must consult or update during the life of a process. The exact field list differs between kernels, but textbook descriptions and real implementations converge on the same core groups.

Field groupExample contentsUsed by
IdentificationProcess ID, parent process ID, user and group IDsSignals, permissions, process tree
Process stateRunning, ready, blocked, stopped, zombieScheduler and wait logic
CPU contextProgram counter, stack pointer, general registers, flagsContext switch code
Scheduling dataPriority, nice value, time slice, accumulated CPU timeScheduler
Memory managementPage table base, address space descriptor, limitsMemory manager, MMU setup
Resource accountingOpen file table, signal handlers, working directorySystem calls, I/O subsystem
Queue linksPointers to run queue, wait queue and sibling entriesKernel list management
Typical field groups in a process control block

Two groups matter most for correctness. The saved CPU context lets the kernel reload registers so execution continues at the right instruction, and the memory management pointer ensures the process sees its own virtual address space after a switch. If either were stored incorrectly, the resumed process would run with corrupted state.

How the PCB enables a context switch

A context switch is the operation in which the kernel saves the CPU state of the current process into its PCB and loads the state of another process from that process’s PCB. The PCB therefore acts as the persistent snapshot of a paused execution.

  1. A timer interrupt, system call or blocking I/O request transfers control to the kernel.
  2. The kernel stores the program counter, stack pointer and registers in the current PCB.
  3. The process state in the PCB changes, for example from running to ready or blocked.
  4. The scheduler selects the next PCB from the run queue according to its policy.
  5. The kernel switches the address space and restores the saved registers of the chosen process.
  6. Execution returns to user mode at the instruction recorded in the restored context.

The cost of this sequence is pure overhead: no useful application work happens while registers are saved and restored. On modern hardware a switch typically takes from about one to several microseconds, but the indirect cost is often larger, because caches and the translation lookaside buffer lose locality when a different address space becomes active.

Process control blocks in real kernels

No production kernel uses a structure formally named PCB; each has its own implementation of the concept. The structures are much larger than textbook diagrams suggest, because they also carry security, tracing and namespace information.

KernelStructureNotable design point
Linuxtask_structOne structure per task; threads and processes share the same type
Windows NTEPROCESS and ETHREADProcess and thread data are split into separate objects
FreeBSDstruct proc and struct threadPer-process and per-thread state are separated
XNU (macOS)Mach task and BSD procMach and BSD layers each keep their own view
How major kernels implement the process control block

In Linux, task_struct occupies several kilobytes and is allocated from a dedicated slab cache. Because Linux represents every thread as a task, threads of one process are distinct entries that share memory and file tables by reference rather than by copying them.

The process control block is often confused with neighboring kernel objects. The distinction is about granularity and ownership: some state belongs to the whole process, some to each thread and some to the CPU itself.

StructureDescribesRelationship to the PCB
Thread control blockOne thread: registers, stack, thread stateSeveral per PCB in multithreaded processes
Page tableVirtual to physical address mappingsReferenced from the PCB memory fields
File descriptor tableOpen files, sockets and pipesPointed to by the PCB, may be shared
Run queueProcesses ready to execute on a CPUContains links to PCBs or thread entries
Kernel stackCall frames while in kernel modeAllocated per thread, located through the PCB
Process control block and neighboring kernel structures

In a multithreaded design, the thread control block holds the CPU context, while the PCB keeps the shared address space and resources. The scheduler then dispatches threads, and the process state shown to users is derived from the states of its threads.

The PCB across the process lifecycle

The PCB is created when a process is created and destroyed only after its parent has collected the exit status. Each lifecycle event leaves a visible trace in its fields.

EventChange to the PCBConsequence
Creation by forkNew PCB copied from the parent, new process IDChild process inherits resources
DispatchState set to running, context loadedProcess uses the CPU
Blocking I/OState set to blocked, moved to wait queueCPU is given to another process
PreemptionContext saved, state set to readyProcess returns to the run queue
ExitState set to zombie, resources releasedParent must read the exit status
ReapingPCB freedProcess ID can be reused
Lifecycle events and their effect on the PCB

The zombie state shows why the PCB can outlive the program: a minimal PCB stays in memory to hold the exit code until the parent calls a wait function. If the parent dies first, the child becomes an orphan process and is adopted by init or a subreaper, which reaps it later.

Limitations and common misconceptions

Because the PCB is central, several misconceptions and engineering limits surround it. Understanding them helps when diagnosing performance problems or reading kernel documentation.

  • The PCB does not contain the program code. It only points to the address space where code and data reside.
  • Process tables are finite. Limits such as the maximum number of process IDs mean a fork bomb can exhaust PCB slots before memory runs out.
  • PCB access must be synchronized. On multiprocessor systems, kernels protect fields with locks or read-copy-update to avoid races.
  • Large PCBs cost cache space. Frequently used fields are grouped together so a context switch touches fewer cache lines.
  • The PCB is a security boundary. Credentials stored in it decide access rights, so corrupting it is a classic privilege escalation target.

In simple terms

A process control block is like a bookmark plus a file folder for every running program. When the computer pauses one program to let another run, it writes down exactly where the first program stopped and what it was using.

Later, the computer opens that folder, restores everything and the program continues as if nothing happened. Without this record, multitasking would be impossible, because the system could not remember the half-finished work of each program.

A practical example

A systems administrator investigates a Linux build server where compilation jobs feel slow. Running a process listing shows dozens of compiler processes in the runnable state and a context switch rate of roughly 40,000 switches per second across eight cores.

Each switch saves registers into one task_struct and restores another, and the frequent changes of address space flush useful cache contents. The administrator reduces the parallel job count from 32 to 10, so fewer PCBs compete in the run queues.

The context switch rate falls by more than half and total build time drops from 22 minutes to about 17 minutes, showing that less scheduler churn produced more useful CPU time.