←Back to Subject
Notes
Notes
Study material and explanations
Diagrams
Diagrams
Visualize concepts easily
Mnemonics
Mnemonics
Tricks to remember faster
One Night Prep
One Night Prep
Short and focused revision
Revision
Revision
Quick summary and key points
Important Questions
Important Questions
Practice most relevant questions
Notes

Process Management: Process Concepts, Process States & Process Control Block (PCB)

Study material and explanations for Unit 2

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.exe or vlc.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:

Figure 2.1: Memory Layout of a Process Inside Main Memory (RAM)
High Addr1. Stack Section (Grows Downward ↓)
Stores temporary data: function parameters, return addresses & local variables
Dynamic2. Heap Section (Grows Upward ↑)
Memory dynamically allocated at runtime using malloc() or new
Static3. Data Section
Stores Global variables and Static variables
Low Addr4. Text (Code) Section
Contains the actual compiled executable machine code instructions

2. 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:

Figure 2.2: The 5-State Process Transition Diagram in Operating Systems
1. NEWProcess is being created
→ Admitted →
2. READYIn RAM waiting for CPU
→ Scheduler Dispatch →
3. RUNNINGInstructions executing on CPU
→ Exit →
5. TERMINATEDFinished execution

(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:

  1. 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).
  2. 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.
  3. 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!)
  4. 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!).
  5. 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!

Figure 2.3: Structure and Fields of a Process Control Block (PCB)
Field 1Process ID (PID)
Unique integer identification number assigned to the process (e.g., PID = 1042)
Field 2Process State
Current state: New, Ready, Running, Waiting, or Terminated
Field 3Program Counter (PC)
Holds the memory address of the NEXT instruction to be executed
Field 4CPU Registers
Saved values of Accumulator, Index Registers, Stack Pointers (for Context Switch)
Field 5CPU Scheduling Info
Process Priority number, pointers to scheduling queues
Field 6Memory Management Info
Base & Limit register values, Page Table or Segment Table pointers
Field 7I/O Status & Accounting Info
List of open files, allocated I/O devices, and total CPU time used

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:

  1. Save the current state (Program Counter & CPU Registers) of Process P1 into P1’s PCB.
  2. 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).