Open In App

Two State Process Model in Operating System

Last Updated : 26 Apr, 2025
Summarize
Comments
Improve
Suggest changes
Share
Like Article
Like
Report

The process in an operating system passes from different states starting from its formation to its completion. A process consists of program data and its associated data and a process control block (PCB). A process may change its state because of the following events like I/O requests, interrupt routines, synchronization of processes, process scheduling algorithms, etc. The process may run or may not and if it is running then that has to be maintained by the systems for appropriate progress of the process to be gained.

Two-State Process Model

The simplest model in the process state will be a two-state model as it consists of only two states that are given below:

  • Running State: A state in which the process is currently being executed.
  • Not Running State: A state in which the process is waiting for execution.

Process Transitions

Running to Blocked

A process moves from the Running state to the Blocked state when it cannot continue its execution due to a dependency or external condition. This typically happens when the process needs to wait for some resource, such as input/output (I/O) operations or access to a resource that is unavailable at the moment.

Examples of conditions that may cause a process to be blocked:

  • Waiting for data from a file or network resource
  • Waiting for user input
  • Waiting for a semaphore or mutex in a multi-threaded environment
  • Accessing a blocked I/O device

Example Scenarios:

  • I/O Wait: A process performing a file read operation moves to the Blocked state while it waits for data to be fetched from storage.
  • Memory Allocation: A process might move to the Blocked state if it requests memory but must wait for memory to be allocated or freed by another process.
  • Synchronization Wait: In multi-threaded applications, a process may enter a Blocked state if it is waiting for a lock or semaphore to be released by another thread.

Blocked to Running

A process transitions from the Blocked state to the Running state when the event it was waiting for is completed, allowing it to resume execution. The process enters the Running state once the required resource becomes available or the condition it was waiting for is fulfilled.

Example transitions:

  • The process waiting for I/O finishes its operation and data becomes available, so the process moves back to the Running state.
  • If a thread was blocked on a lock, once the lock is available, the process can continue its execution.

Role of the CPU Scheduler in this transition:

  • The CPU scheduler plays a key role in managing the transitions from Blocked to Running. Once a process becomes unblocked, the CPU scheduler will determine whether it is eligible to be executed (based on priority, CPU availability, etc.).
  • If the process is ready to run and has the highest priority (or according to the scheduling policy), the CPU scheduler will allocate CPU time to it and move the process to the Running state.

Execution of Process in Two-state Model

A two-state can be created anytime no matter whether a process is being executed or not. 

  • Firstly, when the OS creates a new process, it also creates a process control block for the process so that the process can enter into the system in a non-running state. If any process exit/leaves the system, then it is known to the OS.
  • Once in a while, the currently running process will be interrupted or break-in and the dispatcher (a program that switches the processor from one process to another) of the OS will run any other process.
  • Now, the former process(interrupted process) moves from the running state to the non-running state and one of the other processes moves to the running state after which it exits from the system.
Two-State-process-model
Two State Process Model

Processes that are not running must be kept in a sort of queue, and wait for their turn to execute. In the Queuing diagram, there is a single queue in which the entry is a pointer to the process control block (a block in which information like state, identifier, program counter, context data, etc, are stored in a data structure) of a particular process. 

frame_287
Queuing Diagram

We must know that a queue may have linked list blocks in which each block represents one process. The behavior of the dispatcher can be seen in the queuing diagram, a process that is interrupted is transferred to the queue waiting process, and if the process has been completed, it is terminated. After that again dispatcher takes another process from the queue and executes that process. 

Advantages of the Two State Process Model

  • Simple and easy to understand.
  • It is ideal for basic systems or educational settings.
  • It is useful for basic process management and helps track whether a process is running or waiting for a resource.
  • Ideal for explaining foundational concepts like process scheduling and resource handling.

Limitations of the Two State Process Model

  • Lacks granularity, missing important states like Ready, New, or Terminated.
  • Insufficient for complex scheduling algorithms used in modern operating systems.
  • Oversimplified compared to multi-state models which offer better process tracking and management in real-time, preemptive, or multi-threaded systems.

Applications and Use Cases

Basic Systems that Use a Simple Two-State Model:

  • Early operating systems or simple embedded systems often used the two-state model. These systems are designed with fewer resources and simpler task management, where the overhead of managing multiple process states is unnecessary.
  • Examples include basic batch processing systems or systems with limited task-switching capabilities.

How the Two-State Model Applies to Real-World OS Examples:

  • The two-state model may be found in historical or minimal operating systems, such as early UNIX versions or embedded operating systems designed for small, specialized tasks.
  • It serves as a teaching tool for understanding process scheduling in simple systems before transitioning to more advanced, multi-state models used in modern OS like Linux, Windows, and macOS.

Similar Reads