Course Content
Bonus Section (for Interviews and GATE/Placement prep)
0/2
Operating Systems (OS)
PCB (Process Control Block)

In the world of Operating Systems, managing multiple processes simultaneously is a complex task. To do this effectively, the OS needs to track the state and information of each process. This is made possible through a data structure called the Process Control Block (PCB).


 What is a PCB?

A Process Control Block (PCB) is a data structure maintained by the operating system for every process. It acts like an identity and control file for each active process. The PCB stores all the essential information needed by the OS to track the execution and management of a process.

 

Each time a process is created, the OS allocates a PCB for it. When the process is terminated, its PCB is deleted.

 


 
Why is PCB Important?

  • It allows the OS to switch between processes during multitasking.
  • Maintains process information even when a process is paused or waiting.
  • Helps in saving and restoring the state of a process during context switching.

 

Without the PCB, the OS wouldn’t know the status, priority, or location of processes in memory.


 Components of a PCB

A typical PCB contains the following key elements:

 

  • Process ID (PID)
    A unique identifier assigned to each process.

 

  • Process State
    Indicates the current status of the process: ready, running, waiting, or terminated.

 

  • Program Counter
    Stores the address of the next instruction to be executed for the process.

 

  • CPU Registers
    Contains the data stored in CPU registers during process execution. This data is saved during a context switch.

 

  • Memory Management Info
    Includes pointers to the memory used by the process (e.g., base and limit registers, page tables).

 

  • Accounting Information
    Records time used by the CPU, job or process number, and other tracking details for billing or monitoring.

 

  • I/O Status Information
    Includes a list of I/O devices allocated to the process, and any open files being used.

PCB During Context Switching

When the CPU switches from one process to another, it saves the state of the current process in its PCB and loads the saved state of the new process from its PCB. This mechanism ensures processes can resume from where they left off without errors or data loss.


Summary

The Process Control Block (PCB) is the central structure for process tracking in an operating system. It stores everything needed for the OS to manage, schedule, and control processes effectively. In short, the PCB is like a passport, logbook, and control panel for each process, enabling smooth multitasking and system stability.

0% Complete
WhatsApp Icon

Hi Instagram Fam!
Get a FREE Cheat Sheet on System Design.

Hi LinkedIn Fam!
Get a FREE Cheat Sheet on System Design

Loved Our YouTube Videos? Get a FREE Cheat Sheet on System Design.