Process States || 7-States

The process, from its creation to completion, passes through different phases called process states.  There are seven basic states of process. 

  • Ready, RUN, and WAIT Process States exist in the Main memory.
  • New, Suspended Ready, and Suspended Wait Process states exist in secondary memory.

1. New

When a process is created, it exists in secondary memory. Then, the OS picks up that process from the secondary memory to the main memory to execute it. 

2. Ready

The ready process exists in the main memory. It waits for the CPU to be assigned to it. There may be many processes present in the ready state.

3. Running

Any process in a ready state can be taken by the OS and assigned to the CPU for execution through CPU scheduling algorithms. If we have only one CPU in our system, then only one process will be in execution at a time. If we have N number of CPUs in the system, then N number of processes can be running simultaneously.

4. Block or wait

From the Running state, a process can go to the block or wait state, depending upon

  • Scheduling algorithm (i.e., time quantum, high-priority process)
  • The process can request for some I/O device
  • Interrupt can occur
  • System Call may invoke

When a process requests an I/O, the OS blocks the running process and assigns the CPU to the next processes.

5. Termination or Completion

Os terminates all Processes. When a process finishes its execution, it goes to the termination state. All the context of that process, which exists in PCB, is also deleted.

6.  Suspend Ready

Processes in the ready state that exist in the main memory and are moved to secondary memory due to lack of space in the main memory are called the suspended ready state. It exists in secondary memory

If the main memory is full and a higher-priority process comes for execution, then the OS has to make some space for the higher-priority processes in the main memory by moving the lower-priority process out into the secondary memory. Suspended-ready processes exist in secondary memory until the main memory becomes available for suspended processes.

A process can directly enter into a suspended wait from a new state in case the ready queue in the main memory is full of higher-priority processes. A new process with a lower priority is created. Then, OS put this process in suspension, ready at the secondary level.

7. Suspend wait

The process that is already in a block state or waiting state and is suspended is called suspend wait or suspended block. It exists in secondary memory. When suspended wait processes are awakened, they will go for a block state in the main memory or a suspended ready state in the secondary memory.

Transferring the suspended wait process to the suspended ready state is a good approach because, at the secondary level, we have enough space to accommodate such processes rather than main memory.

Note: These states are also called the life cycle of a process