Definition
Process State Model
The process state model describes the lifecycle of a process through a set of discrete states. These states help the operating system manage CPU allocation and resource distribution effectively.
5-State Model
A common implementation is the five-state model, which accounts for creation, execution, and termination phases:
- New: The process is being created. The OS has built the necessary data structures but has not yet admitted it to the ready queue.
- Ready: The process has all required resources and is waiting for the OS to grant it CPU time.
- Running: The process is currently being executed on the CPU.
- Blocked (Waiting): The process cannot continue until a specific event occurs (e.g., I/O completion or synchronisation signal).
- Exit (Terminated): The process has finished execution or was aborted. The OS is protocolling its resource usage before deleting its data structures.
Visual Representation
State Transitions
- Dispatch: The scheduler selects a process from the ready queue to run next.
- Timeout: The process has used its allocated time slice (quantum) and is returned to the ready queue to allow other processes to run.
- Event Wait: The process initiates an operation (like an I/O request) that forces it to wait.
- Event Occurs: The external event completes, moving the process back to the ready state.
- Release: The process completes its final instruction or is terminated by the parent or OS.
7-State Model (with Suspend)
The seven-state process model expands the traditional 5-state model by adding two suspended states. These states account for situations where processes are swapped out of main memory (RAM) to secondary storage (disk) to free up memory resources.
The Suspended States
- Ready/Suspend: The process is in secondary memory but is ready to run as soon as it is loaded into main memory.
- Blocked/Suspend: The process is in secondary memory and is waiting for an event. Once the event occurs, it moves to the Ready/Suspend state.
Why Suspend Processes?
When the system load is high and main memory is “full,” the OS must manage its resources carefully:
- Freeing RAM: Moving a process to the disk frees up space for active processes.
- Swapping: The OS can “swap out” a blocked process that is likely to remain inactive for a long time.
- System Stability: By suspending processes, the OS prevents the system from crashing due to memory exhaustion.
Processes in a suspended state reside in secondary memory and require a Swap In operation to return to the Ready state before they can get the CPU.