Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
What happens to a PCB when the state of a process changes?
Process Control Block (PCB) is a data structure used by the operating system to store essential information about each process. When a process changes state, the PCB is updated to reflect the new state and preserve the process's context for future execution.
The PCB contains critical information that allows the OS to manage processes effectively during state transitions and context switches.
PCB Components
The important information stored in PCB includes the following −
Process ID (PID) − Unique identifier for each process in the system.
Process State − Current state (Ready, Running, Blocked, Terminated).
Program Counter − Address of the next instruction to be executed.
CPU Registers − Values of all CPU registers including accumulators, base, and general-purpose registers.
Memory Management Info − Memory limits, page tables, segment tables.
I/O Status − List of open files, allocated devices, pending I/O requests.
Scheduling Info − Priority, scheduling queue pointers, time quantum remaining.
PCB Structure
| Process State |
| Process ID (PID) |
| Program Counter |
| CPU Registers |
| Memory Limits |
| I/O Status Info |
| Scheduling Info |
What Happens During State Changes
When a process state changes, the following PCB operations occur −
State Update − The process state field in PCB is updated to reflect the new state.
Context Saving − CPU registers, program counter, and other execution context are saved in the PCB.
Queue Management − PCB is moved to the appropriate scheduling queue (ready queue, blocked queue, etc.).
Resource Information − I/O status, memory allocation details are updated as needed.
Context Switching Process
During context switching between processes, the OS performs these steps −
| Step | Action | PCB Operation |
|---|---|---|
| 1 | Save current process | Store CPU state in current process's PCB |
| 2 | Update process state | Change state field (Running ? Ready/Blocked) |
| 3 | Select new process | Choose PCB from ready queue |
| 4 | Restore new process | Load CPU state from new process's PCB |
| 5 | Update new state | Change state field (Ready ? Running) |
Key Points
The OS maintains a process table containing pointers to all PCBs in the system.
PCB acts as a snapshot of the process at any given moment, enabling seamless state transitions.
Multiple queues (ready queue, blocked queue) organize PCBs based on process states.
Context switching overhead depends on the amount of information stored in the PCB.
Conclusion
When a process changes state, its PCB is updated to reflect the new state and preserve execution context. The PCB serves as the primary mechanism for the OS to manage process state transitions and perform efficient context switching between processes.
