Process State Diagram in Operating System

In this tutorial, we will learn about the process state diagram which defines the various states in which a process can be while it remains in the main memory. By Monika Sharma Last updated : May 07, 2023

Process State Diagram

The Process State diagram illustrates the States in which a process can be in, and it also defines the flow in which a particular state can be achieved by the Process. Let us first take a look at the Process State diagram, which is as follows:

process state diagram

Explanation

  • When a new process is initiated, it is said to be in the new state, which means that the process is under creation.
  • When the process is ready for execution, the long term scheduler transfers it from the new state into the ready state. The process has now entered into the main memory of the system.
  • In the ready state, the processes are scheduled by the short term schedulers, and a queue is maintained in which the processes are serially sent to the processor.
  • After maintaining the queue, the dispatcher then transfers the processes to the running state one by one as per the queue sequence.
  • While being in the running state, the process utilizes the processor. But if there is a requirement of any input or output devices in between the processing, then the process is shifted to the waiting state.
  • When the process is done with the input-output services, then instead of directly going back to the running state, it is again sent to the ready state and is then is scheduled again for going into the running state.
  • This process keeps continuing and when the process completes its execution, it goes into the termination state, which means it exits from the main memory of the system.
  • The black arrow in the diagram, which goes from the running to waiting for state exists only if the operating system follows preemption of processes, i.e. a current running process can be interrupted in between and can be replaced by some other process with high priority. If the OS does not allow preemption, then this switch is not allowed.

Important Terms Used in Process State Diagram

1. Context Switching

Whenever a process is transferred within the system, it moves within different states. These states are known as the process states. When a process goes from one state to another state inside the system, then it is termed as context switching. It can be said that for executing, a process context switches between the different Process States. Context Switching is very important because, without it, a process cannot be executed.

2. Overhead

As we know that the Running State is the most important state as it is the state in which the process executes inside the processor. So, to maximize the use of the processor and to increase the efficiency and performance of any system, the running state must never be empty. But there are cases when a process residing in the running state completes its execution and goes into the termination state, but due to unavailability of any process in the ready state, the dispatcher is not able to transfer any process into the running state and till that time the running state remains empty. This is known as overhead.

3. Degree of Multiprogramming

It can be defined as the maximum number of processes that can be handled by the main memory at any particular instance of time. The degree of multiprogramming is maintained inside the main memory by the Mid Term Schedulers. This increases the speed and performance of the system.

Graphically, the degree of multiprogramming can be represented as follows:

process state diagram (1)

Here, throughput refers to the number of processes residing in the main memory at that particular instance of time. It is also termed as CPU utilization.

4. Dispatcher

The Job of the dispatcher is to dispatch the scheduled processes from the Ready State to the Running State one by one. It should be noted that a process can enter into the running state from no other state but the ready state and this process of transferring the process from the ready state to the running state is performed by the dispatcher.

Enhanced Process State Diagram

The enhanced process state diagram was introduced for maintaining the degree of multiprogramming by the Operating System. The degree of multiprogramming is the maximum number of processes that can be handled by the main memory at a particular instance. It is maintained by the Mid Term Schedulers. Let us first have a look at the diagram and will then talk about the working of the Mid Term Schedulers.

Enhanced process state diagram

The dotted box represents the Main memory of the system, which consists of the Ready state, the Running state, and the Waiting state. The degree of multiprogramming remains constant for a system. As soon as the number of processes in the ready state or the waiting state exceeds the degree of multiprogramming level, then the Mid Term Scheduler starts transferring the processes to the suspended ready state and to the suspended wait state respectively. As soon as the processes residing in the main memory complete their execution and goes into the termination state, the Mid Term Schedulers again transfers them into their respective states in the main memory.

The entire remaining processing inside the main memory is the same as in the normal Process State Diagram. The difference between the two is only that in the enhanced Process state diagram, the degree of multiprogramming is maintained by the Mid Term Schedulers by which, the flooding of processes into the main memory is eliminated, and this increases the processing speed and the performance of the system.

Here, in the enhanced Process state diagram also, the concept of preemption and non-preemption is applicable. If the Operating system allows preemption, then the switching of the process from the running state to ready state directly is allowed. Else, it is restricted if the Operating System follows the no-preemption mode of process scheduling.





Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.