Process Control Block (PCB)
The kernel cannot keep a process in its head. The PCB is the record that survives a context switch and tells the kernel everything it needs.
In plain English
The PCB is a process's ID card and backpack: who it is, what it has, and where it stopped.
By the end you will be able to
- List the main fields of a process control block.
- Explain why the PCB must store saved registers.
- Describe how the process table relates to PCBs.
- Know what information a scheduler reads from a PCB.
What the PCB stores
The process control block stores the process ID, parent and child links, state, program counter, CPU registers, stack pointer, memory-management information, open file descriptors, accounting data, and scheduling priority. It is the kernel's complete snapshot of a process. Different kernels use different layouts, but the categories are universal.
struct PCB {
int pid;
int ppid;
enum State state;
uintptr_t program_counter;
uintptr_t stack_pointer;
uintptr_t page_table;
struct File *open_files;
int priority;
};The process table
The kernel keeps a process table containing the PCB of every live process. A process ID indexes or hashes into that table. When the scheduler chooses a process, it reads the PCB. When a process blocks, the kernel updates its state and moves it to a wait queue. The PCB is the object that links scheduling, memory, and file state together.
Saved context and scheduling data
The saved program counter and registers let the process resume exactly where it stopped. The scheduler also needs priority, recent CPU usage, and state. The memory fields point to page tables or segment descriptors. The file fields point to open file descriptions. Losing any of these fields would make a correct resume impossible.
Key takeaways
- The PCB is the kernel's record of a process.
- It stores identity, state, registers, memory, files, and scheduling data.
- The process table holds the PCBs of all live processes.
- The saved program counter and registers make context switching possible.
Common pitfalls
- Thinking the PCB stores the process's entire code and data; it stores metadata and pointers.
- Forgetting that open file state belongs to the process.
- Assuming every OS uses the same PCB layout.
Kernel notes
- Name five PCB fields and what each is used for.
- Explain why the PCB must be saved on a context switch.
- Know the difference between the process table and a ready queue.
Quick check
1. Which PCB field lets a process resume at the correct instruction?
2. What is the process table?