🧠 What is a PCB (Process Control Block)?

The Process Control Block is a data structure maintained by the Operating System for every active process.

It stores all the information needed to manage, schedule, and resume the process.


📦 PCB Structure — Key Fields

Let’s break the PCB down into its major components:

SectionFieldsDescription
🪪 Process Identification- PID (Process ID)
- PPID (Parent PID)
Uniquely identifies the process
🧠 Processor State- Program Counter (PC)
- CPU Registers
Current CPU state needed for resumption
⏱️ Scheduling Info- Priority
- Scheduling state
- Time slices used
Used by scheduler to decide next process
🧠 Process State- New
- Ready
- Running
- Blocked
- Terminated
Current status of the process
📦 Memory Info- Base & limit registers
- Page tables / Segment tables
Tracks memory layout of the process
🔁 Accounting Info- CPU time used
- Start time
- User/system time
Used for billing, monitoring
🔌 I/O Status- List of open files
- I/O devices assigned
Tracks files/devices being used
📡 Interprocess Communication (IPC)- Signals
- Message queues
- Pipes
Required for cooperating processes

🔍 Visual Representation of PCB

+------------------------+
| Process ID (PID)       |
+------------------------+
| Parent Process ID      |
+------------------------+
| Process State          |
+------------------------+
| Program Counter        |
+------------------------+
| CPU Registers          |
+------------------------+
| Scheduling Info        |
+------------------------+
| Memory Management Info |
+------------------------+
| I/O Status             |
+------------------------+
| Accounting Info        |
+------------------------+
| IPC / Signal Info      |
+------------------------+

⚙️ What Happens During a Context Switch?

During a context switch, the OS:

  1. Saves the current process’s state into its PCB.

  2. Loads another process’s state from its PCB.

  3. Updates CPU registers and program counter accordingly.

The PCB is the anchor point for putting a process to sleep and waking it up exactly where it left off.


🔒 Where Is PCB Stored?

  • Usually in kernel space

  • In OS-managed data structures like process table

  • Not accessible to user-space processes


🧠 Interview-Ready Definition:

A Process Control Block (PCB) is a data structure used by the OS to store all the essential information about a process — including its state, registers, memory layout, scheduling data, and I/O resources. It enables the OS to manage, schedule, and context-switch processes reliably.