A process is a program in execution — an active entity with a program counter, stack, data section, and resources. While a program is passive (a file on disk), a process is the realization of that program loaded into memory and executing on the CPU.
Process vs Program
| Aspect | Program | Process |
|---|---|---|
| Nature | Passive (file on disk) | Active (loaded in memory, executing) |
| Lifespan | Permanent until deleted | From creation to termination |
| Resources | None (just occupies disk space) | CPU, memory, I/O, file handles |
| Relationship | One program can spawn many processes | e.g., opening 3 Chrome tabs = 3 processes |
| Storage | Static on disk | Dynamic in RAM + CPU registers |
Process Control Block (PCB)
The OS maintains a PCB for every process. It’s the data structure that represents the process internally.
| Field | Description |
|---|---|
| Process ID (PID) | Unique numeric identifier |
| Process state | Current state: new, ready, running, waiting, terminated |
| Program counter | Address of the next instruction to execute |
| CPU registers | Saved during context switch (accumulators, index registers, stack pointer) |
| Scheduling info | Priority, queue pointers |
| Memory info | Page tables / segment tables |
| I/O status | List of open files, allocated devices |
Process States
New → Ready → Running → Terminated
↕ Wait (I/O)
Ready ↔ Running ↔ Wait
- New — process being created
- Ready — in memory, waiting for CPU allocation
- Running — currently executing on CPU
- Waiting (Blocked) — waiting for I/O, signal, or event
- Terminated — finished execution, PCB still exists until parent reads exit status
Zombie & Orphan
- Zombie: process terminated but PCB not yet cleaned up (parent hasn’t called
wait()) - Orphan: parent terminated before child — adopted by
init(PID 1)
Context Switching
The CPU switches between processes by saving the current process’s state into its PCB and loading the next process’s state from its PCB. Context switching is pure overhead — no useful work is done during the switch.
Q: What are the five states of a process?
A: New (being created), Ready (waiting for CPU), Running (executing), Waiting (blocked for I/O/event), Terminated (finished). Ready and Waiting are most common — a process typically alternates between them.
Q: What information is stored in a PCB?
A: PID, process state, program counter, CPU registers (saved during context switch), scheduling priority, memory management info (page tables), and I/O status (open files, devices).
Q: Is a process the same as a program?
A: No. A program is a passive set of instructions on disk. A process is an active instance loaded in memory with its own execution context. One program can spawn multiple processes.
Q: What are zombie and orphan processes?
A: A zombie has finished executing but still has an entry in the process table because the parent hasn’t read its exit status. An orphan’s parent terminated before it — the kernel re-parents orphans to init (PID 1).
Q: Why is context switching considered overhead?
A: During a switch, the CPU saves/loads registers and flushes caches but executes zero user code. High switching frequency degrades throughput.
Premium Content
Unlock Process Management & States and all premium lessons with a subscription.
From ₹199.99/year — See plans