Process State in OS
Overview
The program under execution is called Process. Process is an active entity. Process goes through different states throughout the life cycle during the process execution, which is known as process states. All the information associated with the process is stored in the Process Control Block (PCB).
Process States in OS
We'll learn about 'Process States' and the many states processes that occur throughout the lifespan of a process in this post. The states that the process can have differed from one Operating System to the next. However, just a few frequent states are depicted in the diagram.
Let's first understand what is a process. The process is defined as any program that goes under execution. One example of creating the process is using the fork() system call. The parent process uses a fork() system call which will create the child process. It is possible that at the same time, multiple processes are created and stored in memory.
Whenever the process creation is taking place process is in a new state and when the process gets terminated it is in the terminated state or completed state.
The states of the process are stored in the Process Control Block(PCB). PCB is a special data structure that stores information about the process.
Let’s learn about the various states a process can go through in detail in the next section along with the process state diagram.
List of States of the Process
New State
This is the first state of the process life cycle. When process creation is taking place, the process is in a new state.
Ready State
When the process creation is completed, the process comes into a ready state. During this state, the process is loaded into the main memory and will be placed in the queue of processes which are waiting for the CPU allocation.
When the process is in the creation process is in a new state and when the process gets created process is in the ready state.
Running State
Whenever the CPU is allocated to the process from the ready queue, the process state changes to Running.
Block or Wait State
When the process is executing the instructions, the process might require carrying out a few tasks that might not require CPU. If the process requires performing Input-Output task or the process needs some resources that are already acquired by other processes, during such conditions process is brought back into the main memory, and the state is changed to Blocking or Waiting for the state. Process is placed in the queue of processes that are in waiting or block state in the main memory.
Terminated or Completed
When the entire set of instructions is executed and the process is completed. The process is changed to a terminated or completed state.During this state the PCB of the process is also deleted.
It is possible that there are multiple processes present in the main memory at the same time.
Suspend Ready
So whenever the main memory is full, the process which is in a ready state is swapped out from main memory to secondary memory. The process is in a ready state when goes through the transition of moving from main memory to secondary memory, the state of that process is changed to Suspend Ready state. Once the main memory will have enough space for the process, the process will be brought back to the main memory and will be in a ready state.
It’s possible that the process is waiting or a blocked state can be swapped out to secondary memory. Let’s understand in which state the process in waiting or block state will go.
Suspend Wait or Suspend Blocked
Whenever the process that is in waiting for state or block state in main memory gets to swap out to secondary memory due to main memory being completely full, the process state is changed to Suspend wait or Suspend blocked state.
Enroll in Scaler Topics Operating System Free course with certification now to get certified and master OS from industry experts!
Conclusion
- The program under execution is called process.
- Process goes through different states throughout the life cycle which are called process states.
- New, Ready, Running, Waiting or Block, Terminated or Completed, Suspend ready, and Suspend wait or blocked are different states in which process might go during the life cycle.
- The state of the process is stored in Process Control Block (PCB).