A process control block (PCB) is the data structure that stores all information about a running program in an operating system. It acts as the OS's record card for each process, tracking its state, resources, and execution details.
Every time you launch a program, the OS creates a PCB for it. This block contains metadata about the process including:
The OS uses this information to manage multitasking, switching between processes, and allocating resources. When a process terminates, its PCB is deleted.
While implementations vary, most PCBs contain these key elements:
| Component | Purpose |
|---|---|
| Process state | Tracks whether the process is running, waiting, ready, etc. |
| Program counter | Indicates where in the program execution should resume |
| CPU registers | Stores the contents of CPU registers when the process isn't running |
| Memory management info | Contains pointers to memory management tables |
| Accounting info | Tracks CPU usage and process execution time |
PCBs enable modern computing by allowing multiple programs to run simultaneously. Without them, operating systems couldn't efficiently manage:
For example, when you switch from a word processor to a web browser, the OS uses PCBs to save the processor's state for the word processor and load the saved state for the browser.
Many people confuse PCBs with similar concepts:
Each serves different purposes in different contexts. The PCB remains the fundamental unit for process management in operating systems.
When I studied computer science, I built a simple operating system simulator that used PCBs to manage processes. Seeing how the OS switched between processes using these data structures helped me understand their critical role in modern computing.