What is a Process Control Block (PCB) and what does it store?
A PCB is the kernel data structure holding everything the OS needs to manage one process: its ID, state, saved registers, program counter, memory information, open files and scheduling data.
Explain it simply
A PCB is the file the OS keeps on each process, like the admission record a college keeps for every student: roll number, branch, fee status, attendance. Without it the OS could not pause a process and resume it later.
Typical contents:
- Process ID and parent process ID
- Process state (ready, running, waiting)
- Program counter and CPU registers, saved when the process is switched out
- Scheduling information: priority, queue pointers
- Memory management information: page table or base and limit registers
- Accounting data: CPU time used
- I/O status: open file descriptors, devices allocated
Example
In Linux the PCB is a structure called task_struct. A simplified picture:
PCB of process 4021
pid: 4021 ppid: 1180
state: READY
pc: 0x4011a2 registers: saved
priority: 20
page table -> 0x7ffd3000
open files: 0 (stdin), 1 (stdout), 2 (stderr), 5 (log.txt)During a context switch the kernel copies the CPU's registers into the outgoing process's PCB and loads the incoming process's saved registers from its own PCB. That is exactly what lets a process resume as if nothing had happened.
What to say in the interview
"The PCB is the kernel's per-process record. It holds the PID, state, saved program counter and registers, memory maps, open files and scheduling info. A context switch saves the old process's CPU state into its PCB and restores the next one's. In Linux it is task_struct."
Common mistakes
- Thinking the PCB lives in the process's own memory. It is in kernel memory, out of the process's reach.