Skip to content

Process Control Block (PCB) in Operating System

1. Introduction to PCB

The Process Control Block (PCB) is a data structure maintained by the Operating System (OS) for each process. It contains important information required to manage and control a process.

πŸ’‘ Think of PCB as an identity card for a process! It helps the OS track the process state, resources, and execution details.


2. Role of PCB in Process Management

The PCB is created when a process is created and deleted when a process terminates.
It helps the OS perform:
βœ… Process scheduling – Decides which process runs next.
βœ… Resource allocation – Manages CPU, memory, and I/O devices.
βœ… Process state tracking – Keeps track of execution progress.
βœ… Inter-process communication (IPC) – Helps processes exchange data.


3. Structure of a PCB (Components)

The PCB contains various fields to store essential information about a process.

πŸ“Œ Key Components of a PCB:

FieldDescription
Process ID (PID)A unique identifier assigned to each process.
Process StateCurrent status: New, Ready, Running, Waiting, Terminated.
Program Counter (PC)Stores the address of the next instruction to be executed.
CPU RegistersStores registers like accumulator, stack pointer, etc.
Memory Management InfoBase and limit registers, page tables.
I/O Status InfoList of allocated I/O devices and files.
CPU Scheduling InfoPriority, scheduling algorithms, process queues.
Accounting InfoCPU time used, process start time, execution details.
Parent Process IDIdentifies the parent process (if created using fork()).

βœ” Example: When a program like “Google Chrome” runs, the OS creates a PCB to track its execution.


4. Diagram of a PCB

Here’s a visual representation of a PCB:

------------------------------------------------
| Process ID (PID) | 101 |
| Process State | Running |
| Program Counter (PC) | 0x005A4F |
| CPU Registers | R1, R2, R3, ... |
| Memory Info | Base: 0x2000, Limit: 0x4000 |
| I/O Devices | Printer, Disk, Monitor |
| CPU Scheduling Info | Priority: High |
| Accounting Info | CPU Time: 5 ms |
------------------------------------------------

Each process has its own PCB stored in the Process Table.


5. How PCB Helps in Context Switching?

πŸ”„ Context Switching occurs when the CPU switches from one process to another.

  • The current process’s state and register values are stored in the PCB.
  • The next process’s PCB is loaded, restoring its state and registers.

βœ” Example:
If you’re running MS Word and a browser, the OS switches between their PCBs to manage execution.


6. Conclusion

βœ” The Process Control Block (PCB) is a vital data structure used for process management.
βœ” It stores process state, memory details, and CPU scheduling information.
βœ” It helps in context switching, scheduling, and resource allocation.