What is a process control block (PCB)?

Why Interviewers Ask This

Interviewers use this question to quickly assess whether a candidate has the foundational knowledge required for Operating Systems development. It reveals whether you understand the building blocks that more complex concepts rely on.

Answer

A Process Control Block (PCB) is the data structure maintained by the OS kernel to represent and track every process. When a process is created, the OS creates a PCB; when the process terminates, the PCB is freed. PCB contains: (1) Process state: ready, running, waiting, etc.; (2) Program counter (PC): address of next instruction to execute; (3) CPU registers: all register values (accumulator, index registers, stack pointer) — saved/restored on context switches; (4) CPU scheduling information: process priority, scheduling queue pointers; (5) Memory management information: page tables, segment tables, base and limit registers; (6) Accounting information: CPU time used, wall-clock time, time limits, account numbers; (7) I/O status information: list of I/O devices allocated, open file tables; (8) Process ID (PID): unique identifier; (9) Parent PID (PPID); (10) Process group, session; (11) Signal masks; (12) Open file descriptors. Context switching: when CPU switches from Process A to Process B, the OS saves A's CPU state into A's PCB, loads B's state from B's PCB, then resumes B. This takes time (overhead) — hundreds of nanoseconds to microseconds. Frequent context switching wastes CPU time. PCB in Linux: the task_struct structure (~600 fields in modern Linux kernel). Every process and thread has a task_struct.

Pro Tip

Before answering, structure your response: one-line definition → real-world analogy → concrete example from a project. This makes even complex Operating Systems answers easy to follow.