Open In App

Three State Process Model in Operating System

Last Updated : 26 Jan, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Pre-requisites: 

In this article, we’ll be discussing a three-state process model in an operating system and also discussing the need for this process model, how the process executes, what will be the possible transition that can occur, and last its benefits and some drawbacks. Before, learning about the below three-state process model, it is recommended to read the previous two-state process model.

Need for Three-State Process Model

The two-state process model was an amazing process model consisting of only two states i.e, running and not-running, that means when the process is running it will execute, otherwise not and the CPU will sit idle. The major drawback of using a two-state process model is that when the dispatcher allows a new process to enter from not-running to the running state, the process might still be waiting for some other event like an input/output operation and therefore, the dispatcher must traverse the queue and find a not-running process that is ready for execution and this thing will lead to decrease in performance. Now, to overcome this situation, the three-state process model is introduced. In the three-state model, the non-running state of the two-state model is further divided into two different states and totally now there are 3 states:

  1. Ready State– A state in which a process is ready and waiting for its execution.
  2. Blocked State– A state in which a process doesn’t execute until and unless a process event occurs, like completion of an Input/Output operation.
  3. Running State– A state in which the process is currently executing.

Execution of Process in Three-State Model

In this model, the OS ensures that only one process must stay in the running state but there can be multiple processes also that are in the blocked state and waiting for their execution. The processes that need to be in the running state first enter into a ready state and then put into the running state. Now within the running state, a process may arise the 2 conditions that are either the process goes to the event wait or may get a time-out condition then get exit.

If the process has the timed-out condition, the process is again put into the ready state until it gets executed. If a process has an event wait condition then the process goes to the blocked state and then to the ready state. Once, both the conditions get true, the process is dispatched to the running state after which the process terminates.

Three-State Model

Three-State Model

Possible State Transitions

There can be various events that make the state transition for a process. The possible state transitions for a three-state process model are given below:

  1. Ready-> Running– A process moves from ready to running state when the OS selects a new process for a run and the system chooses only one process to execute in a ready state.
  2. Running-> Ready– A process moves from running to the ready state when either the time-out condition is met or another may be due to priority issues that have been assigned to processes by an OS and a process having a higher priority enters the system. This transition is handled by a process scheduler.
  3. Running-> Blocked/Waiting– A process moves from running to a blocked state when the process’s demand is not fulfilled like a process demanding larger memory or demanding some other resources that are not available and therefore, it allows the next process in a ready state to execute. This transition is also handled by a process scheduler.
  4. Blocked/Waiting-> Ready– A process moves from blocked state to ready state by a signal from the Input or output device manager that the given request has been satisfied and the process can continue for execution.
  5. Running-> Exit– A process gets terminated after its full execution.

Benefits

  • The benefits will be the same as the two-state model like it provides an efficient way for improving the two-state process model.

Drawbacks

  • CPU performance issues when the CPU is idle and not executing any process.
  • After the process termination, the data or information is not stored anywhere.

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads