Process Management: Process Concepts, Process States & Process Control Block (PCB)
1. Process Concepts: What is a Process?
A Process is formally defined as “a program in execution”.
- When a software program (like
chrome.exeorvlc.exe) sits on your hard disk, it is just a passive file of binary instructions called a Program. - The moment you double-click that file, the Operating System loads it into Main Memory (RAM), allocates CPU registers and resources to it, and it comes alive as an active Process!
Simple Real-Life Analogy: A Printed Recipe Book sitting on a shelf is a Program (passive). A Chef actively cooking that recipe in the kitchen using ingredients and utensils is a Process (active)!
Comparison: Program vs Process
| Basis | Program | Process |
|---|---|---|
| 1. Nature | A Passive (Static) entity stored on disk containing a set of instructions. | An Active (Dynamic) entity currently executing in Main Memory (RAM). |
| 2. Storage Location | Stored on Secondary Storage (Hard Disk / SSD) as an .exe file. |
Loaded into Main Memory (RAM) and CPU registers. |
| 3. Lifespan | Permanent (exists on disk until deleted by the user). | Temporary / Limited (born when launched, dies when terminated). |
| 4. Resource Requirement | Requires only disk space to store the file. | Requires CPU time, RAM space, I/O devices, and a PCB. |
Memory Layout of a Process in RAM
When the OS loads a program into RAM to create a process, its memory space is divided into 4 sections:
malloc() or new2. Process States (The 5-State Process Lifecycle)
As a process executes, it changes its State depending on what it is currently doing. From creation to completion, every process passes through 5 fundamental states:
(Note: From RUNNING, if a process requests I/O or waits for an event, it moves to 4. WAITING / BLOCKED, and once I/O completes, it returns to 2. READY! If a timer interrupt occurs in RUNNING, it goes directly back to 2. READY).
Detailed Explanation of the 5 Process States:
- New State: The process is just being created (e.g., user double-clicked an icon, and the OS is creating its PCB and loading it from disk).
- Ready State: The process has been loaded into Main Memory (RAM), has all resources it needs, and is sitting in the Ready Queue, waiting only to be assigned to the CPU by the Short-Term Scheduler.
- Running State: The CPU has been allocated to the process, and its machine instructions are actively being executed on the processor. (On a single-core CPU, only ONE process can be in the Running state at any instant!)
- Waiting (or Blocked) State: The process cannot continue executing on the CPU right now because it is waiting for some external event to occur—such as completion of a Disk I/O read/write, user keyboard input, or a signal from another process. Once the I/O finishes, the process moves back to the Ready state (never directly to Running!).
- Terminated (Exit) State: The process has finished executing its last statement (or was killed due to an error). The OS deallocates its memory and deletes its PCB.
3. Process Control Block (PCB) / Task Control Block
How does the Operating System keep track of 100 different processes running at the same time? For every single process, the OS creates and maintains a special kernel data structure in RAM called the Process Control Block (PCB)!
Analogy: The PCB is like a Patient’s Medical File / Student ID Dossier—it holds every single detail the OS needs to pause a process today and resume it from the exact same spot 10 milliseconds later!
4. Context Switching & Threads Overview
A. What is Context Switching?
When the CPU switches from executing Process P1 to executing Process P2, the OS must:
- Save the current state (Program Counter & CPU Registers) of Process P1 into P1’s PCB.
- Load (restore) the saved state of Process P2 from P2’s PCB into the CPU registers.
This process of saving the context of the old process and loading the context of the new process is called a Context Switch. (Note: Context switching time is pure overhead because the CPU does no useful user work while switching).
B. Threads (Lightweight Processes)
- A Thread is a lightweight sub-process and the basic unit of CPU utilization within a process.
- Each thread has its own Thread ID, Program Counter, Register Set, and Stack, but shares the Code Section, Data Section, and OS resources (open files) with other threads belonging to the same process—making thread creation and context switching much faster than full processes!
💡 Exam Preparation Tips for DAVV BCA
- “Explain Process States and Process Control Block (PCB) with neat diagrams” is a guaranteed 8-mark question in almost every DAVV BCA Operating System paper!
- Always list all 7 fields of the PCB (
Process ID,Process State,Program Counter,CPU Registers,CPU Scheduling Info,Memory Management Info,I/O & Accounting Info).