Skip to content

State Transition Diagram in Operating System

1. Introduction

In an Operating System (OS), a process goes through different states during its execution. The State Transition Diagram visually represents these process states and the transitions between them.

πŸ’‘ Why is it important?

  • Helps in understanding process scheduling.
  • Shows how processes change states due to CPU execution, I/O operations, or termination.

2. Process States in OS

A process typically moves through the following five states:

StateDescription
NewThe process is created but not yet ready for execution.
ReadyThe process is loaded into RAM, waiting for CPU allocation.
RunningThe process is actively executing instructions on the CPU.
Waiting (Blocked)The process is waiting for an I/O operation or resource.
Terminated (Exit)The process has finished execution or has been killed.

3. State Transition Diagram

Here’s the visual representation of process states and their transitions:

                  +----------------------+
----------> | New |
| +----------------------+
| |
| (Admitted by OS) v
| +----------------------+
|----------> | Ready |
| +----------------------+
| |
| (Scheduled by CPU) v
| +----------------------+
|--------->| Running |
| +----------------------+
| (Process completes or needs I/O)
| / \
| / \
| v v
| +----------------+ +----------------+
| | Waiting | | Terminated |
| +----------------+ +----------------+
| | |
| | (I/O Complete) | (Process Ends)
| | |
| v X
| +----------------+
| | Ready |
| +----------------+
|
| (Back to Ready state when I/O is done)

4. State Transitions Explained

1️⃣ New β†’ Ready

  • The OS admits a new process into the Ready queue.

2️⃣ Ready β†’ Running

  • The CPU scheduler selects a process from the Ready queue and assigns CPU time.

3️⃣ Running β†’ Terminated

  • The process completes execution or is forcefully terminated.

4️⃣ Running β†’ Waiting (Blocked)

  • The process requests I/O (e.g., waiting for file input).

5️⃣ Waiting β†’ Ready

  • Once the I/O operation is complete, the process moves back to Ready.

6️⃣ Running β†’ Ready

  • If the CPU switches to another process (preemption), the current process returns to Ready state.

5. Example of Process Execution

βœ” Example Scenario: Running a Video Player

  • New β†’ When the OS loads the video player.
  • Ready β†’ The OS schedules it but waits for CPU.
  • Running β†’ The video is playing (CPU allocated).
  • Waiting β†’ It pauses to buffer more data (I/O operation).
  • Ready β†’ Buffering is done; it’s ready to play again.
  • Terminated β†’ You close the video player.

6. Conclusion

βœ” The State Transition Diagram explains how a process moves between different states.
βœ” The OS manages process transitions to ensure efficient CPU utilization.
βœ” Process Scheduling determines when and how a process moves between these states.