Fundamentals 8 min read

Understanding Process State Transitions: The Ready‑Running‑Blocked Triangle

The article explains the three fundamental process states—Running, Ready, Blocked—their characteristics, how they convert between each other, the role of the Process Control Block, Linux‑specific state extensions, and provides illustrative code and diagrams to clarify OS scheduling concepts.

IT Learning Made Simple
IT Learning Made Simple
IT Learning Made Simple
Understanding Process State Transitions: The Ready‑Running‑Blocked Triangle

Three Basic Process States

Running : CPU is executing the process. Characteristics: occupies CPU, executes instructions, only one running process on a single‑core CPU (multiple on multi‑core).

Ready : Process is prepared and waiting for CPU time. Characteristics: does not lack resources, only needs a CPU time slice, placed in the ready queue.

Blocked : Process is paused waiting for an event (I/O, resource, signal, user input). Characteristics: cannot run even if CPU is idle, must wait for the blocking condition to be cleared.

State‑Transition Diagram

┌─────────────┐
               │             │
               │   Running   │
               │  (Running)  │
               │             │
               └──────┬──────┘
                      │
          time slice used up / preempted │
                      ↓
               ┌─────────────┐
               │             │
               │   Ready     │
               │   (Ready)   │
               │             │
               └──────┬──────┘
                      │
               selected by CPU
                      │
                      ↓
        ┌─────────────────────────────────────┐
        │   Process execution …                │
        │   needs I/O / resource / signal      │
        └─────────────────────────────────────┘
                      │
                      ↓
               ┌─────────────┐
               │             │
               │   Blocked   │
               │  (Blocked)  │
               │             │
               └──────┬──────┘
                      │
          I/O completed / event occurs │
                      ↓
               returns to Ready queue

Detailed Conversions

Running → Ready

Trigger conditions:
1. Time slice expires
2. Preempted by a higher‑priority process

Example:
Xiao Ming's 5‑minute time slice runs out. He still has work left, but must yield the CPU so another process can run.

Ready → Running

Trigger condition:
Scheduler selects the process from the ready queue.

Example:
The scheduler scans the ready queue, picks Xiao Ming, and he can finally work.

Running → Blocked

Trigger conditions:
- Process explicitly requests I/O
- Waits for a resource
- Waits for a signal

Example:
Xiao Ming is waiting for a client email. The client hasn't replied, so Xiao Ming must wait and cannot continue work.

Blocked → Ready

Trigger conditions:
- I/O operation finishes
- Resource becomes available
- Signal arrives

Example:
The client finally replies. Xiao Ming can resume work, but must again wait for CPU scheduling.

Suspend State

Modern OSes also have a "Suspend" state where a process is swapped out to disk, freeing physical memory. It can be either "Ready‑Suspend" or "Blocked‑Suspend" and can be entered due to memory pressure, user‑initiated suspension (Ctrl+Z), or system maintenance.

Process Control Block (PCB)

The PCB stores all information about a process, including PID, state, program counter, CPU registers, scheduling data, memory management info, I/O status, and statistics. Example PCB layout:

┌─────────────────────────────────────┐
│            Process Control Block    │
├─────────────────────────────────────┤
│ PID: 1234                           │
│ State: Running                      │
│ Priority: 5                         │
├─────────────────────────────────────┤
│ CPU registers: PC, SP, AX, …        │
├─────────────────────────────────────┤
│ Memory management: page table ptr… │
├─────────────────────────────────────┤
│ File descriptors: 0‑stdin, 1‑stdout │
│                2‑stderr, 3‑/path │
├─────────────────────────────────────┤
│ Statistics: user time 100s, sys 50s│
│ Memory usage: 128 MB                │
└─────────────────────────────────────┘

Ready and Blocked Queues

The OS maintains multiple queues. Ready queues (often per priority) hold processes that can run, while blocked queues hold processes waiting for specific I/O events such as disk, network, or keyboard input.

Linux‑Specific Process States

R: Running / Runnable
S: Interruptible sleep (waiting, can be woken by signal)
D: Uninterruptible sleep (waiting for I/O)
T: Stopped (signal‑paused)
Z: Zombie (exited, parent not reaped)
X: Dead (about to be reclaimed)

Commands to view states: ps aux, top

State‑Transition Code Example

// Pseudocode: process state transition
// Process is running
process->state = RUNNING;

// Time slice expires
if (time_slice_expired()) {
    process->state = READY;
    scheduler.add_to_queue(process);
}

// Need I/O
if (need_io) {
    process->state = BLOCKED;
    io_queue.add(process);
    schedule(); // schedule other processes
}

// I/O completion interrupt
void io_interrupt() {
    Process* p = io_queue.remove();
    p->state = READY;
    scheduler.add_to_queue(p);
}

Parent‑Child Process Relationship

After fork(), the parent receives the child's PID and continues execution, while the child starts at the return point of fork() with its own memory space. The parent can call wait() to block until the child exits; otherwise the child becomes a zombie until the parent reaps it.

Summary

The three fundamental states—Running, Ready, Blocked—form the core of OS scheduling. Transitions occur when a time slice ends, the scheduler picks a ready process, a process needs I/O, or an I/O event completes. Only Ready processes can become Running, and Blocked processes must first become Ready. Understanding these conversions and the PCB is essential for grasping operating‑system behavior.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Linuxschedulingoperating systemprocess statesblocked stateprocess control blockready state
IT Learning Made Simple
Written by

IT Learning Made Simple

Learn IT: using simple language and everyday examples to study.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.