Process States and the PCB — Revision Notes
Process states and the PCB are foundational OS knowledge that scheduling and context-switching build on. Expect "draw the process state diagram" and "what does the PCB store?" in written and viva rounds.
Process states
A process moves through five states:
- New — being created.
- Ready — loaded, waiting for the CPU.
- Running — instructions executing on the CPU.
- Waiting/Blocked — waiting for I/O or an event.
- Terminated — finished execution.
Key transitions: Ready→Running (dispatch), Running→Ready (preemption/timeout), Running→Waiting (I/O request), Waiting→Ready (I/O complete).
The Process Control Block (PCB)
The PCB is the OS data structure that stores everything about a process, used to save/restore it on a context switch:
| PCB field | Holds |
|---|---|
| PID | unique process id |
| Process state | new/ready/running/… |
| Program counter | next instruction address |
| CPU registers | saved register values |
| Scheduling info | priority, queue pointers |
| Memory info | page tables, limits |
| I/O status | open files, devices |
Exam Tricks & Tips
- 🎯 Learn the five states and their transitions — "Running→Ready = preemption (timer)", "Running→Waiting = I/O request", "Waiting→Ready = I/O done".
- 🎯 Only one process is in the Running state per CPU core at a time.
- 🎯 The PCB is saved on a context switch so the process can later resume exactly where it left off — its role in a nutshell.
- 🎯 A process can go Running→Ready (preempted) but never Waiting→Running directly — it must pass through Ready.
- 🎯 The PCB stores the program counter and registers — precisely what must be restored to resume execution.
- 🎯 A zombie process has terminated but its PCB entry lingers until the parent reads its exit status; an orphan has lost its parent.
- ❌ Common mistake: thinking a blocked process competes for the CPU — it can't be scheduled until its event completes and it returns to Ready.
Expected pattern
"Draw/label the process state diagram", "what does the PCB contain?", "which transition is preemption?", "difference between zombie and orphan", and "can a waiting process run directly?".
Quick recap
Five states: New, Ready, Running, Waiting, Terminated. Transitions: dispatch, preemption, I/O request/complete. The PCB stores PID, state, PC, registers, scheduling/memory/I-O info — saved and restored on context switches so a process resumes exactly. Blocked processes must return to Ready before running.
Process States and the PCB — Flashcards
Cover the answer, recall, then check. 12 cards on process states and the PCB.
Q1. Name the five process states.
A1. New, Ready, Running, Waiting (Blocked), and Terminated.
Q2. What does the Ready state mean?
A2. The process is loaded in memory and waiting to be assigned the CPU by the scheduler.
Q3. What transition is "preemption"?
A3. Running → Ready — the process is moved off the CPU (e.g. its time quantum expired) though still runnable.
Q4. What causes a Running → Waiting transition?
A4. The process requests I/O or waits for an event, so it can't proceed until that completes.
Q5. Can a Waiting process go directly to Running?
A5. No — when its event/I-O completes it goes Waiting → Ready, then is dispatched to Running.
Q6. What is the PCB?
A6. The Process Control Block — the OS data structure holding all information about a process.
Q7. Name four things the PCB stores.
A7. PID, process state, program counter, CPU registers (also scheduling info, memory info, I/O status).
Q8. Why is the PCB critical for context switching?
A8. It saves a process's PC and registers so execution can be restored exactly where it stopped.
Q9. How many processes can be Running per CPU core at once?
A9. Exactly one — the CPU executes a single process per core at a time.
Q10. What is a zombie process?
A10. A terminated process whose PCB entry remains until the parent reads its exit status.
Q11. What is an orphan process?
A11. A process whose parent has terminated; it is typically adopted by the init/systemd process.
Q12. Which two PCB fields must be restored to resume a process?
A12. The program counter (next instruction) and the CPU registers.
Process States and the PCB
The OS juggles dozens of processes on a handful of CPUs by tracking, for each one, what it is doing right now (its state) and everything needed to resume it (its PCB). These two concepts underpin scheduling, context switching and every OS diagram in an exam.
Core idea: a process moves through a small set of states (new, ready, running, waiting, terminated) as it competes for the CPU and waits on I/O. The Process Control Block (PCB) is the kernel data structure that stores a process's complete context — its ID, state, registers, memory maps and more — so it can be paused and resumed transparently.
How it works
Beginner — the five-state model
admit dispatch exit
[New] ------> [Ready] ---------> [Running] ------> [Terminated]
^ <--------- |
| (timer/preempt) |
| | I/O or event wait
+---- [Waiting] <---+
(I/O complete)
- New: being created.
- Ready: loaded, waiting for a CPU (in the ready queue).
- Running: executing on a CPU.
- Waiting/Blocked: waiting for I/O or an event; not competing for the CPU.
- Terminated: finished, resources being reclaimed.
Intermediate — the transitions that matter
Only the scheduler moves a process Ready → Running (dispatch). A running process goes:
- → Ready when its time slice expires or it is preempted (still runnable).
- → Waiting when it requests I/O or blocks on a resource (cannot run until the event completes).
- Waiting → Ready (not → Running) when the I/O completes — it must queue again for the CPU.
The key distinction: Ready = wants CPU, has everything else; Waiting = cannot proceed until an external event.
Advanced — the PCB
Each process has one PCB (kernel-resident). It holds:
- PID and parent PID; process state.
- Program counter and CPU registers (saved on a switch).
- Memory-management info (page tables, base/limit).
- Scheduling info (priority, queue pointers).
- Accounting (CPU time used) and I/O status (open files, devices).
On a context switch, the OS saves the running process's CPU state into its PCB and loads the next process's state from its PCB. The PCB is literally the process's saved snapshot.
Worked example — a read() call's state journey
A process is Running and executes read(file):
- Data isn't in memory, so it issues an I/O request and transitions Running → Waiting; the OS saves its registers into its PCB and dispatches another Ready process.
- The disk finishes and raises an interrupt; the OS moves the process Waiting → Ready and puts it in the ready queue.
- When the scheduler picks it, Ready → Running: the OS reloads its context from the PCB and it resumes right after the
read.
Note it never jumps Waiting → Running directly — completing I/O only makes it eligible, not scheduled.
Interview & exam relevance
Very common: "draw the process state diagram", "difference between Ready and Waiting/Blocked", "what does a PCB contain", and "which transition does the scheduler control?" (Ready → Running). GATE loves the subtle point that I/O completion sends a process to Ready, not Running.
Tricks & gotchas
- Ready ≠ Waiting. Ready means "give me a CPU"; Waiting means "I need I/O/event first".
- There is no Waiting → Running edge; it always passes through Ready.
- The PCB is per-process and kernel-owned; switching processes = save one PCB, load another.
- Mnemonic states: "New, Ready, Running, Waiting, Terminated" (NRRWT).
Confusing the Ready and Waiting (Blocked) states, or drawing a direct Waiting → Running arrow. A blocked process that finishes its I/O returns to the Ready queue and must be scheduled again before it runs. Ready processes only lack a CPU; waiting processes lack a resource/event entirely.
- ✓- Five states: New, Ready, Running, Waiting (Blocked), Terminated.
- ✓- Ready = has everything but a CPU; Waiting = blocked on I/O/event.
- ✓- Scheduler controls Ready → Running (dispatch); I/O completion sends Waiting → Ready.
- ✓- The PCB stores a process's full context: PID, state, PC, registers, memory maps, scheduling/accounting info.
- ✓- Context switch = save current PCB, load next PCB.
- ✓A process cycles through New→Ready→Running with detours to Waiting for I/O and back to Ready. The PCB is its saved snapshot — everything the OS needs to pause and resume it — making the ready/waiting distinction and PCB contents core OS exam material.
Process States and the PCB — Worked Example
Worked Example
Problem: Trace the state transitions of a process through this timeline on a single-CPU system, naming each transition and what the OS does to the PCB:
- Process P is admitted. 2. The scheduler picks P. 3. P issues a disk read. 4. The disk finishes. 5. A higher-priority process preempts P. 6. P is chosen again and completes.
Solution:
The five-state model is: New → Ready → Running → (Waiting/Blocked) → Terminated. Only one process is Running per CPU; the rest that are runnable sit in the Ready queue; those awaiting I/O sit in a wait queue.
- Admitted: New → Ready. The OS creates a PCB for P (PID, state, program counter, registers, memory maps, open-file table) and puts P on the ready queue.
- Dispatched: Ready → Running. The dispatcher loads P's saved context from its PCB into the CPU; P executes.
- Disk read (I/O request): Running → Waiting. P cannot proceed until data arrives. The OS saves P's context into its PCB, moves P to the disk's wait queue, and the scheduler dispatches another ready process.
- Disk completes (interrupt): Waiting → Ready. The I/O completion interrupt marks P runnable again; P returns to the ready queue (it does NOT go straight to Running — the CPU may be busy).
- Preemption: (this concerns whichever process was running) Running → Ready. When a higher-priority process arrives, the current running process is preempted back to Ready; its context is saved to its PCB. This is why a Running → Ready edge exists only under preemptive scheduling.
- Dispatched again and finishes: Ready → Running → Terminated. On completion the OS reclaims P's resources; the PCB is removed after exit status is collected.
The PCB is the OS's per-process record; every transition is essentially the OS saving/restoring the PCB's context and moving the process between queues.
Answer: New→Ready (admit), Ready→Running (dispatch), Running→Waiting (disk I/O), Waiting→Ready (I/O done, not directly to Running), Running→Ready (preempted), Ready→Running→Terminated (finish). Each move updates/saves the PCB and changes which queue holds the process.
- ✓- Five states: New, Ready, Running, Waiting/Blocked, Terminated; only one Running per CPU.
- ✓- I/O completion sends a process to Ready (not straight to Running); Running→Ready happens only with preemption.
- ✓- The PCB stores each process's context (PC, registers, memory, files); transitions save/restore it and re-queue the process.