OPERATING SYSTEMS/Student Engineering Notebook
Page 04·notes
PROCESSES, THREADS & CONCURRENCY—~20 MIN READ·GATE CS LENS

Process States & Transitions: 5-State vs 7-State Models

“The dynamic lifecycle of computation: New, Ready, Running, Waiting, Terminated and Swapping.”

1.The 5-State Process Lifecycle

As a process executes, it changes state according to hardware conditions and scheduler choices. In the classic 5-State model, a process exists in exactly one of the following states at any instant:

1. New: The process is being created (memory structures initialized, PID allocated), but is not yet loaded into main memory or placed in the ready queue.

2. Ready: The process resides in main memory and is prepared to execute immediately as soon as the CPU scheduler allocates a core.

3. Running: Instructions are being executed directly on the CPU hardware core.

4. Waiting (Blocked): The process cannot execute until some external event occurs (such as I/O completion, page fault resolution, or child process exit).

5. Terminated: The process has finished execution; its resources are deallocated, awaiting parent cleanup.

2.The 7-State Model: Why Swapping & Suspended States Are Essential

In real operating systems, the 5-state model has a fatal vulnerability: Physical RAM is finite. If the degree of multiprogramming is high and multiple processes block on slow disk I/O, main memory quickly becomes saturated with dormant, waiting processes.

Under the 5-state model, if every process in RAM is blocked waiting for I/O, the CPU would sit completely idle despite hundreds of jobs queued on disk. To solve this, modern operating systems introduce a third scheduler: the Medium-Term Scheduler (The Swapper).

The Medium-Term Scheduler frees up precious physical memory frames by swapping out inactive processes from RAM to secondary storage (Swap Space on SSD or HDD). This expands the lifecycle with two new suspended states:

6. Blocked-Suspend (Suspended-Blocked): The process resides in secondary storage (swap disk) AND is still waiting for an I/O event to occur.

7. Ready-Suspend (Suspended-Ready): The process resides in secondary storage, but the event it waited for has finished. It is ready to run as soon as space is allocated in main memory.

The Critical GATE Transition: What happens when an I/O event completes for a process in Blocked-Suspend? The process moves from Blocked-Suspend → Ready-Suspend, NOT directly to Ready! Because physical memory has not yet been allocated to it, it transitions to Ready-Suspend on disk first. Only when the medium-term scheduler swaps it back into RAM does it enter Ready.

3. Complete 7-State Process Lifecycle Architecture

LIVE EXAM DRAWING STUDIOOperating Systems · 10 Marks (Theory + Diagram)

7-State Process Lifecycle with Swapper

Appears in 85% of University End-Term OS Papers & GATE CS

Step 1 of 5 · Exam Sheet View
MAIN MEMORY (RAM) · ACTIVE EXECUTION BOUNDARYSECONDARY STORAGE (SWAP DISK) · SUSPENDED STATE BOUNDARY
Step 1: Draw the RAM vs Disk Memory Boundaries

Draw two horizontal dotted partition boxes: Upper box is Main Memory (RAM), lower box is Secondary Storage (Swap Space).

2 Marks: Boundary demarcation & memory labels.
✍️ HOW TO DRAW ON EXAM ANSWER SHEET

Professors first look for the clear spatial division between RAM (active execution) and Swap Disk (suspended states). Label both clearly.

⚠️ COMMON EXAM BLUNDER / MARKS LOST

Placing Ready-Suspend inside RAM. Ready-Suspend means PCB is in RAM but memory pages are on DISK.

✎ Tip:Always use dotted lines for memory boundaries and solid lines for state boxes.
Figure 2.3 — Complete 7-State Process Lifecycle Architecture showing Main Memory (RAM) vs. Secondary Storage (Swap Space) separated by the Medium-Term Scheduler (Swapper).
LABORATORY · INTERACTIVE SIMULATION —Concept Exploration

4. Interactive Process State Transition Simulator

Click on the kernel trigger buttons to observe how process state transitions occur, which queues are affected, and what the OS kernel does behind the scenes.

Process Lifecycle State Machine

5-State Process Machine Simulator

NEW
Process is created; PCB allocated in kernel RAM.
READY
In main memory, queued in Ready List awaiting CPU dispatch.
RUNNING
Instructions currently executing on CPU hardware core.
WAITING
Blocked waiting for I/O completion or synchronization event.
TERMINATED
Execution complete; awaiting parent wait() to reap exit code.
Available Kernel Events from NEW:
Last Kernel Operation:

Process is in initial READY state. Waiting for CPU allocation.

5.Crucial State Transition Rules & Misconceptions

MythA process can transition directly from Waiting (Blocked) to Running.
RealityImpossible! A Waiting process MUST first transition to the Ready queue before it can run.

When I/O completes, the CPU is already occupied executing another process. The waking process must join the Ready Queue and await its turn from the short-term CPU scheduler.

MythA process transitions from Running to Waiting when its time slice expires.
RealityA timer expiration moves a process from Running to READY, not Waiting!

Waiting means the process CANNOT run even if the CPU were 100% idle. A preempted process is fully capable of running; it simply gave up the CPU to be fair to other ready processes.

MythWhen I/O finishes for a swapped-out process (Blocked-Suspend), it immediately jumps into the RAM Ready queue.
RealityIt transitions to READY-SUSPEND on disk! It enters RAM Ready only after the Swapper allocates memory frames.

Main memory might still be 100% full. The kernel moves it from the disk-blocked list to the disk-ready list until the Medium-Term Scheduler can swap out another victim or reclaim frames.

GATE LENS · EXAM PREPARATION

6. GATE Lens & Verified PYQs

Syllabus focus, recurring numerical patterns, common traps, and clearly labelled exam practice. Questions remain source-pending until an official paper and answer key are attached.

EXAM WEIGHTAGE & FOCUS:

State transition validity and 5 vs 7-state transitions are consistently tested in GATE CS.

recurring exam patterns:
  • •Listing possible state transitions and identifying illegal transitions.
  • •Analyzing transitions in 7-state models (Ready-Suspend, Blocked-Suspend) with swapping.
  • •Identifying which scheduler manages which transition (Long-term: New → Ready; Short-term: Ready → Running; Medium-term: Ready/Blocked ⇄ Suspended).
⚠ common student traps:
  • •There is NO direct transition from Waiting → Running.
  • •There is NO direct transition from New → Running.
  • •Transition from Running → Ready is only possible in PREEMPTIVE scheduling systems.
  • •Blocked-Suspend → Ready-Suspend occurs upon I/O event completion while the process is on disk.

Exam Practice / Source Verification Required

1 problem
GATE-style question · 1 MarkBlocked → Ready → Running (==pink:Never Blocked → Running==).

In an operating system with preemptive scheduling, which of the following process state transitions is NEVER possible?

A. Ready → Running
B. Running → Ready
C. Blocked → Running
D. Running → Blocked
RAPID REVIEW · NOTEBOOK SUMMARY

7. 1-Minute Panic Revision

core principle:

“5 States: New → Ready ⇄ Running → Terminated. Running → Waiting → Ready. 7 States add Ready-Suspend & Blocked-Suspend on Disk.”

must-remember principles:
  • •Running → Waiting: Process blocks voluntarily for I/O or event.
  • •Waiting → Ready: Event finished. Enters Ready queue.
  • •Running → Ready: Preemption (Time slice expired or higher priority process arrived).
  • •Blocked-Suspend → Ready-Suspend: Event finishes while swapped to secondary storage.
  • •Medium-Term Scheduler: Controls degree of multiprogramming via swapping (RAM ⇄ Disk).
critical exam pitfalls:
  • •Blocked/Waiting processes NEVER jump directly to the CPU core (Blocked → Running is impossible).
  • •Non-preemptive OS has NO Running → Ready transition (processes run until voluntary block or exit).
  • •Blocked-Suspend does NOT become Ready in RAM when I/O finishes; it becomes Ready-Suspend on Disk!
decision flow & invariants:
[ 5-STATE & 7-STATE PROCESS LIFECYCLE DECISION FLOW ] ┌──────────────────────────────── PHYSICAL RAM ───────────────────────────────┐ │ │ │ [NEW] ──(Long-Term Admit)──> [READY] ◄──(Dispatcher Dispatch)──► [RUNNING] │ │ │ ▲ (Timer Preemption) │ │ │ │ │ │ │ │ (Swap Out) ▲ │ │ (Swap In) (I/O Wait) │ │ │ │ │ │ ▼ │ │ │ ▼ │ [WAITING] │ │ │ │ │ │ └───────────────────────────────┼────┼──────────────────────────────────┼─────┘ │ │ │ Medium- │ │ Medium- │ Swap Out Term │ │ Term ▼ (Memory Pressure) │ │ ┌───────────────────────────────┼────┼──────── SECONDARY STORAGE (DISK) ──────┐ │ ▼ │ │ │ [READY-SUSPEND] ◄────(I/O Completes)──── [BLOCKED- │ │ (Disk Ready) SUSPEND] │ │ │ └─────────────────────────────────────────────────────────────────────────────┘
SOURCE TRANSPARENCY & CITATIONS

Primary Academic References & Exam Sources

Every concept in Notes From a B.Tech Brain is synthesized from authoritative academic texts, seminal peer-reviewed research, verified exam archives, and renowned university lectures.

Primary Academic Texts
Operating System Concepts (10th Edition)↗by Silberschatz, Galvin, Gagne · Chapter 3: Processes (Section 3.1.2: Process State & Suspended States)

Official Chapter 3 lecture slides covering process states, transitions, and ready queue mechanics.

ACADEMIC STANDARD
Operating Systems: Three Easy Pieces (OSTEP)↗by Remzi H. Arpaci-Dusseau & Andrea C. Arpaci-Dusseau · Chapter 4: The Abstraction: The Process (Process States)

Clear exposition of process state machine: Running, Ready, and Blocked with state transition diagram.

ACADEMIC STANDARD
Curated University Lecture Series
NPTEL: Operating Systems (IIT Kharagpur)↗Prof. Santanu Chattopadhyay · Module 2: Process States, PCB and State Transitions

IIT Kharagpur lecture on process lifecycle, state queues, and medium-term swapper scheduling.

LECTURE SERIES
ALTERNATIVE PEDAGOGICAL PERSPECTIVES

If the textbook derivation did not click immediately, consult these targeted video lessons:

Process States in Operating System | SchedulersGate Smashers (Varun Singla) (14 mins)

Direct lecture explaining New, Ready, Running, Waiting, Terminated, and how the medium-term scheduler swaps blocked processes.

Watch Lesson↗
Process State in Operating SystemNeso Academy (13 mins)

Whiteboard lecture breaking down exact transition triggers (admit, dispatch, interrupt, I/O wait, I/O completion).

Watch Lesson↗
RECOMMENDED YOUTUBE LECTURES & EDUCATORS: MODULE 2: PROCESSES, THREADS & CONCURRENCY

Curated lectures on Process Lifecycle, PCB Memory Layout, Fork() System Calls & Multi-threading Models:

Gate Smashers · L-1.5: Process States in OS & Schedulers↗Instructor: Varun Singla · Covers: 5-State vs 7-State Process Life Cycle, Suspended states, Long/Medium/Short-term schedulers

Rapid intuitive mastery of process state transitions and state diagram numericals.

Open YouTube↗
Gate Smashers · L-1.12: User Level vs Kernel Level Threads↗Instructor: Varun Singla · Covers: User-Level Threads (ULT) vs Kernel-Level Threads (KLT), TCB structure, Concurrency models

Clear breakdown of blocking I/O behavior, thread context switches, and kernel space mapping.

Open YouTube↗
Neso Academy · fork() and exec() System Calls Walkthrough↗Instructor: Neso Academy · Covers: fork() execution trees, Return values (PID > 0, PID == 0), Zombie and Orphan processes

Visual tree diagram derivations of fork() return values and process hierarchies.

Open YouTube↗
Knowledge Gate · Process vs Thread & Fork GATE Numericals↗Instructor: Sanchit Jain · Covers: GATE PYQ derivations on nested fork() loops, shared vs private thread resources, PCB fields

Exam trick cases on how many times printf() executes in tricky fork() loops.

Open YouTube↗