Open In App

Two State Process Model in Operating System

Last Updated : 17 Dec, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

Pre-requisite: States of a Process in Operating Systems

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.

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. 

Queuing Diagram

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. 


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads