Operating Systems

Process States

New, ready, running, waiting, terminated — and the events that move a process between them.

Level: beginner

What is it?

A process or thread state describes what it is currently able to do from the scheduler's perspective. Common textbook states are new, ready, running, waiting/blocked, and terminated; real operating systems use richer state machines and distinguish runnable tasks from tasks sleeping in different ways.

Why does it matter?

The state explains why a task is not currently using the CPU. A ready task can run when scheduled; a blocked task needs an event such as I/O completion or lock availability before it becomes runnable.

Mental model

Imagine a queue at a service desk. Ready tasks are waiting for CPU time; a running task is being served; a blocked task is waiting for an external event and should not occupy the ready queue.

How it works

  • Ready means eligible to run, not currently executing.
  • Running means the task currently owns a CPU execution slot.
  • Blocked/waiting means the task awaits an event and usually cannot make progress merely by receiving more CPU time.
  • Preemption moves a running task back to ready when its time slice ends or a higher-priority task should run.
  • Termination releases or schedules cleanup of resources, but process accounting and child reaping may continue.

Steps

  • A process becomes ready after creation and successful initialization.
  • The scheduler dispatches it, moving it to running.
  • It requests blocking I/O, so the kernel marks it waiting and runs another task.
  • When I/O completes, the task becomes ready; it runs again when selected.

Real-world usage

  • Interpreting task listings and scheduler traces.
  • Calculating waiting time, turnaround time, and response time in scheduling problems.
  • Diagnosing a service where tasks are blocked on disk, locks, or network I/O.

Common mistakes

  • Treating ready and waiting as synonyms; only ready tasks are eligible for CPU dispatch.
  • Assuming every running task voluntarily yields; timer interrupts allow preemption.
  • Confusing a process with a single thread; multithreaded processes have several schedulable execution contexts.

Interview questions

What event moves a blocked task to ready?

Completion of its awaited event, such as I/O, a timer, or a synchronization condition becoming true.

A running task's time slice expires. What is its next state?

Usually ready if it remains runnable; the scheduler can select it again later.

Prerequisites

Related concepts

Continue learning

Browse the full computer science library