5 State Process Model in Operating System
The Five-State Process Model is developed from the Two-State Model. If all processes in the Not-running state are ready to run, the two-stage model is efficient; however, it is not always true. Some processes in the Not-running state may be waiting for an event or performing an I/O activity. A process must be created for each program to run a program. The process can or cannot run, but if a process is running, it has to be supported by the operating system for the right progress of the process to be gained.
The best way to fix this issue is to divide the Not-running state into two states: Ready and Blocked state.
Reason for New State
The main memory in previous models was considered to be large enough to accommodate all programs, but this is not the case. The size of today's programs is very large. It is not possible to load all processes into the main memory.
The program does not load into the main memory for the new process when creating a new process. In the main memory, the operating system only saves a little amount of information about the process. When enough space is available, the long term scheduler sends the program to the main memory. Such a process is said to be in a new state.
Reason for Terminated State
When a process completes execution in the previous models, its resources are instantly released. However, another process may require this data in the future.
The child process is considered to be at an end-of-life condition. The child's process is still in memory but cannot be executed. For example, when a child process completes execution, the operating system saves its data till the parent call waits () function.
Five-state process model states
The five states that are being used in this process model are as follows:
It refers to a new process that has been created but has not yet been approved for execution by the operating system. Although a new process has not been loaded into the main memory, its process control block has been created.
After a new state process, a process moves from a new to a ready state. When a process is in the ready state, it signifies it has been loaded into the main memory and is ready to run. In the ready state, the process must wait for the processor to respond; once the processor responds, the process advances to the processor for execution. It's worth noting that several processes in a multi-programming environment can remain in the ready state.
All of the processes that are executing on the CPU are in the running state.
The running state indicates that the procedure is starting from a new and ready state. If the process is in its critical section, other processes must wait in the Ready state.
The blocked state applies to all processes that quit the CPU and enter the waiting state. When the CPU becomes available, processes in the blocked state are moved to the ready state and then to the running state.
The exit state refers to a process that has been terminated from the CPU and the main memory.
Execution of Five-state process in Two-state Model
This model has five states: new, ready, running, blocked, and exit. When a new job/process arrives in the queue, it is first accepted to the queue and then moves to the ready state. The process is now in the running state while in the Ready state. A process in the running state has two conditions: it either proceeds to the event wait, or it times out.
If the process has timed out, it moves to the ready state because the process has not finished its execution. If a process has an event wait condition, it enters the blocked state and the ready state. If both conditions are true, the process enters a running state after dispatching, and following which, it is freed and finally terminated.
Five-State Process Model State Transitions
Various events lead to a process's state shift. The 5-state process model's probable state transitions are given below:
1. Null -> New
A new process is created for the implementation of a process.
2. New -> Ready
The system would transition the process from new to ready, and it is now ready for running. In this instance, a system may set a restriction to prohibit many processes from running concurrently; otherwise, performance may suffer.
3. Ready -> Running
The operating system now chooses a process for running, and the system selects single process in a ready state for running.
4. Running -> Exit
If a process indicates that it is now complete or has been aborted, the system terminates it.
5. Running -> Ready
This transition occurs when the running process has achieved its maximum running time for continuous execution.
6. Running -> Blocked
If a process requests something for which it is waiting, it is placed in the blocked state. For example, a process can require resources that aren't currently available, or it could be waiting for an Input/Output operation or another process to complete before proceeding.
7. Blocked -> Ready
When the event for which the process has been waiting occurs, the process switches from blocked to ready state.
8. Ready -> Exit
The transition is only allowed in a few circumstances since a parent process can terminate a child's process at any time in some systems.
Advantages and Disadvantages of the five-state process model
There are various advantages and disadvantages of the five-state process model. Some advantages and disadvantages of the five-state process model are as follows:
Next TopicBest operating system for gaming