Five State Process Model
Five-State Process Model is an extension of the Two-State Model. The two-stage model is efficient if all the processes in the Not-running state are ready for execution but this may not be true. Some processes in the Not-running state might be waiting for some event or I/O operation. Thus, the dispatcher cannot simply select the process from the front of the queue. The dispatcher would have to scan the queue to search for the process to execute. It degrades performance.
The best way to solve this problem is to split the Not-running state into two states: Ready State and Blocked State.
Five-State Process Model States
- Running: The currently executing process.
- Waiting/Blocked: Process waiting for some event such as completion of I/O operation, waiting for other processes, synchronization signal, etc.
- Ready: A process that is waiting to be executed.
- New: The process that is just being created. The Program Control Block is already being made but the program is not yet loaded in the main memory. The program remains in the new state until the long term scheduler moves the process to the ready state (main memory).
- Terminated/Exit: A process that is finished or aborted due to some reason.
You may be wondering why we have new state and terminated state.
Reason for new state
The most common use of a new state is most OS limits the number of processes that can be in the main memory. This is because a large number of processes can lead to thrashing which results in low CPU utilization. The CPU only keeps some information about the new process in the main memory. The program is not yet loaded. The program waits for long term scheduler to move it to the main memory.
Get ButtWait!’s stories in your inbox
Join Medium for free to get updates from this writer.
Reason for terminated state
When a process terminates, the OS frees its data. But there might be some other process that might need this data. So, the OS reserves the data temporarily. For example, when a child process finishes the execution, the OS preserves information about the child until the parent process call wait(). The child process is still consuming resources like memory but not executing.
Five-State Process Model State Transitions
New -> Ready: The long term scheduler picks up a new process from second memory and loads it into the main memory when there are sufficient resources available. The process is now in ready state, waiting for its execution.
Ready -> Running: The short term scheduler or the dispatcher moves one process from ready state to running state for execution.
Running -> Terminated: The OS moves a process from running state to terminated state if the process finishes execution or if it aborts.
Running -> Ready: This transition can occur when the process runs for a certain amount of time running without any interruption. For example, if we use round-robin to schedule processes, then the running process will move to the ready state after time quantum. Another example is if the priority of a process in the ready state is more than the priority of the currently running process, then OS may preempt the running process and move it to ready state.
Running -> Waiting: A process is put in the waiting state if it must wait for some event. For example, the process may request some resources or memory which might not be available. The process may be waiting for an I/O operation or it may be waiting for some other process to finish before it can continue execution.
Waiting -> Ready: A process moves from waiting state to ready state if the event the process has been waiting for, occurs. The process is now ready for execution.
Drawbacks of the five-state model
There is one major drawback of the five-state model. As we know, the processor works much faster than I/O devices. Therefore, a situation may occur where every process might go to waiting/blocked state. The CPU stays idle until atleast one process leaves the waiting state. This degrades performance.
We can overcome the problem by adding another state in the model, which is Suspend State. You can read about it in the original article.
Read the Original Article: Process state model







