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 in Main memory.
- New, Suspended Ready and Suspended wait Process states exist in secondary memory.
When a process is created, it exists in secondary memory. Then, OS picked up that process from secondary memory to the main memory to execute it.
Ready process exists in main memory. It waits for CPU to be assigned to it. There may be many processes present in the ready state.
Any process in ready state can be taken by OS and assign it to 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 CPU’s in system then N number of processes can have 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)
- Process can request for some I/O device
- Interrupt can occur
- System Call may invoke
When a process request for a I/O then the OS block the running process and assign the CPU to the next processes.
5. Termination or Completion
Os terminates the all Processes. When a process finishes its execution, it goes to termination state. All the context of that process which exist in PCB, also deleted.
6. Suspend Ready
Processes in the ready state exist at main memory are moved to secondary memory due to lack of space in main memory is called suspended ready state. It exist at secondary memory
If the main memory is full and a higher priority processes comes for the execution then the OS have to make the 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 at secondary memory until the main memory gets available for suspended processes.
A process can direct enter into suspended wait from new state in case of, if ready queue in main memory is if full of higher priority processes. And a new process having lower priority is created. Then OS put this process in suspended ready at secondary level.
7. Suspend wait
The process which is already in block state or waiting state and is suspended then it called suspend wait or suspended block. It exists at secondary memory. When suspended wait processes are waked up, Then they will go for block state in main memory or suspended ready state at secondary memory.
Transfer of suspended wait process to suspended ready state is a good approach because at secondary level we have enough space to accommodate such processes rather than main memory.
Note: These states also called life cycle of a process