BCS401 Operating System Semester IV · AY 2025-26 onward
Unit 3 · CPU Scheduling, Threads & Deadlocks

Lecture 2: Process states & transition diagram

Learning outcomes

  • Explain the different process states and illustrate them using a state transition diagram.

Prerequisites

Process concept Basic idea of CPU scheduling Ready queue and CPU allocation Basic understanding of I/O operations

Lecture Notes

Main content

Process States & Transition Diagram

Learning Outcome

Explain the different process states and illustrate them using a state transition diagram.


Introduction

A process is a program in execution. While executing, a process does not remain in one condition all the time. It moves through a number of states depending on whether it is being created, waiting for the CPU, running on the CPU, waiting for an event, or finishing execution.

These states help the operating system keep track of process activity and make scheduling decisions correctly. Although different operating systems may use slightly different names, the standard model commonly includes five basic states: new, ready, running, waiting, and terminated.

Key Idea

A process state tells us what the process is doing at a particular moment and whether it is eligible to use the CPU.

Basic Process States

The standard model commonly includes five basic states. The table below summarizes their roles and triggers:

State Description & Activity Typical Trigger / Next Step
New The process is being created; the OS is allocating required data structures. Moves to Ready once admitted into the system.
Ready In main memory, completely ready to run, but waiting for CPU assignment. Moves to Running when selected by the dispatcher.
Running The process's instructions are currently being executed by the CPU. Moves to Waiting (I/O), Ready (Interrupt), or Terminated.
Waiting / Blocked The process cannot continue until a specific event occurs (e.g., I/O completion). Moves back to Ready once the event completes.
Terminated The process has finished execution or was stopped permanently. Final state; the OS deallocates its resources.

Why These States Are Needed

The operating system may manage many processes at the same time. Some may be waiting for the CPU, some may be performing I/O, and one may be running. By maintaining process states, the operating system can:

  • Identify which processes are eligible for execution.
  • Move processes correctly between CPU and waiting phases.
  • Maintain process queues such as the ready queue and waiting queue.
  • Support proper scheduling and resource allocation.

State Transition Diagram

A process changes its state because of system events such as admission, dispatch, I/O requests, I/O completion, interruptions, or exit. These movements are shown using a state transition diagram.

Explanation of Transitions

  • New → Ready: When the OS admits the newly created process into memory and places it in the ready queue, it moves to the ready state.
  • Ready → Running: When the short-term scheduler selects a process from the ready queue and the dispatcher gives it the CPU.
  • Running → Waiting: If a running process requests I/O or must wait for some event, it cannot continue using the CPU and moves to waiting.
  • Waiting → Ready: Once the event it was waiting for is completed (e.g., I/O completion), it becomes eligible for execution again.
  • Running → Ready: In a preemptive system, a running process may be interrupted (time slice expires or higher-priority process arrives) and moved back to ready.
  • Running → Terminated: When the process completes its execution or is explicitly terminated by the OS.

Ready Queue and Waiting Queue

Processes in the ready state wait in the ready queue for CPU service. Processes in the waiting state are usually placed in waiting queues associated with specific I/O devices or events.

This separation is important because a waiting process is not ready to use the CPU, while a ready process is fully prepared to run but is waiting only for processor allocation.

Important Distinction

Ready means the process is fully able to run but lacks a CPU.
Waiting means the process is blocked and cannot run yet, even if the CPU becomes completely free.

Relationship with Schedulers

The process state model is closely related to the different schedulers:

  • Long-term scheduler: Admits jobs into the system, influencing the movement toward the ready state.
  • Short-term scheduler: Selects a ready process and moves it to the running state.
  • Medium-term scheduler: May suspend (swap out) and later reintroduce processes in systems that use virtual memory swapping.

For the basic state diagram, the short-term scheduler is the most directly involved because it controls the rapid, continuous transitions between the ready and running states.

Practical Significance

Understanding process states is essential because many operating system topics depend on them. CPU scheduling chooses among ready processes. Synchronization may cause processes to wait. I/O operations frequently move processes from running to waiting and back again.

In short, the process state transition diagram is one of the most fundamental models in operating systems. It provides a clear picture of how the OS manages process execution from creation to completion.

```

Worked Example

Worked Example: Tracking a Process Through State Changes

Consider a process P1 submitted by a user.

  1. P1 is created. It first enters the New state.
  2. The operating system admits P1 into memory. Now it moves to the Ready state.
  3. The CPU scheduler selects P1. The dispatcher gives it the CPU, so it enters the Running state.
  4. P1 requests disk input. It cannot continue execution until the I/O is complete, so it moves to the Waiting state.
  5. The disk operation finishes. P1 becomes eligible to run again and returns to the Ready state.
  6. The scheduler again selects P1. P1 moves back to the Running state.
  7. P1 completes execution. It enters the Terminated state.

State sequence:

New → Ready → Running → Waiting → Ready → Running → Terminated

This example shows that a process may enter the running state more than once before termination, especially when I/O operations are involved.

One-Page Summary

One-Page Summary: Process States & Transition Diagram

A process is a program in execution. During its lifetime, a process moves through different states. The common five-state model includes new, ready, running, waiting, and terminated.

In the new state, the process is being created. In the ready state, it is in memory and waiting for CPU allocation. In the running state, its instructions are being executed by the CPU. In the waiting state, it is waiting for an event such as I/O completion. In the terminated state, it has finished execution.

The process state transition diagram shows how a process moves from one state to another. A new process is admitted to the ready state. The scheduler dispatches a ready process to the running state. A running process may move to waiting when it requests I/O, return to ready after I/O completion, move back to ready if it is preempted, or move to terminated when execution ends.

The ready state and waiting state are different. A ready process can run as soon as the CPU becomes available. A waiting process cannot run yet because it is waiting for some event.

Process states are important because they form the basis of CPU scheduling, synchronization, I/O handling, and general process management in the operating system. The state transition diagram provides a compact and clear model of how the operating system controls process execution from creation to completion.