- OS - Home
- OS - Needs
- OS - Overview
- OS - History
- OS - Components
- OS - Structure
- OS - Architecture
- OS - Services
- OS - Properties
- Process Management
- Processes in Operating System
- States of a Process
- Process Schedulers
- Process Control Block
- Operations on Processes
- Inter Process Communication (IPC)
- Context Switching
- Multi-threading
- Scheduling Algorithms
- Process Scheduling
- Types of Scheduling
- Scheduling Algorithms Overview
- FCFS Scheduling Algorithm
- SJF Scheduling Algorithm
- Round Robin Scheduling Algorithm
- HRRN Scheduling Algorithm
- Priority Scheduling Algorithm
- Multilevel Queue Scheduling
- Lottery Scheduling Algorithm
- Starvation and Aging
- Turn Around Time & Waiting Time
- Burst Time in SJF Scheduling
- Process Synchronization
- Process Synchronization
- Solutions For Process Synchronization
- Hardware-Based Solution
- Software-Based Solution
- Critical Section Problem
- Critical Section Synchronization
- Mutual Exclusion Synchronization
- Peterson's Algorithm
- Dekker's Algorithm
- Bakery Algorithm
- Semaphores
- Binary Semaphores
- Counting Semaphores
- Mutex
- Turn Variable
- Bounded Buffer Problem
- Reader Writer Locks
- Test and Set Lock
- Monitors
- Sleep and Wake
- Race Condition
- OS Deadlock
- Introduction to Deadlock
- Conditions for Deadlock
- Deadlock Handling
- Deadlock Prevention
- Deadlock Avoidance (Banker's Algorithm)
- Deadlock Detection and Recovery
- Deadlock Ignorance
- Memory Management
- Memory Management
- Contiguous Memory Allocation
- Non-Contiguous Memory Allocation
- First Fit Algorithm
- Next Fit Algorithm
- Best Fit Algorithm
- Worst Fit Algorithm
- Fragmentation
- Virtual Memory
- Segmentation
- Buddy System
- Slab Allocation
- Overlays
- Paging and Page Replacement
- Paging
- Demand Paging
- Page Table
- Page Replacement Algorithms
- Optimal Page Replacement Algorithm
- Belady's Anomaly
- Thrashing
- Storage and File Management
- File Systems
- File Attributes
- Structures of Directory
- Linked Index Allocation
- Indexed Allocation
- Disk Scheduling Algorithms
- FCFS Disk Scheduling
- SSTF Disk Scheduling
- SCAN Disk Scheduling
- LOOK Disk Scheduling
- I/O Systems
- I/O Hardware
- I/O Software
- OS Types
- OS - Types
- OS - Batch Processing
- OS - Multiprocessing
- OS - Hybrid
- OS - Monolithic
- OS - Zephyr
- OS - Nix
- OS - Linux
- OS - Blackberry
- OS - Garuda
- OS - Tails
- OS - Clustered
- OS - Haiku
- OS - AIX
- OS - Solus
- OS - Tizen
- OS - Bharat
- OS - Fire
- OS - Bliss
- OS - VxWorks
- OS - Embedded
- OS - Single User
- Miscellaneous Topics
- OS - Security
- OS Questions Answers
- OS - Questions Answers
- OS Useful Resources
- OS - Quick Guide
- OS - Useful Resources
- OS - Discussion
Operating System - States of a Process
A process in an operating system can undergo various states during its lifecycle in the system. First of all, when you run a program it becomes a process. Then the operating system manages the process by transitioning it through different states based on the availability of resources and the process's requirements.
Different operating systems can have different names for these states or phases, but the fundamental concepts remain similar. Commonly we have three types models to represent the states of a process in an operating system −
Two State Model
In the simplest model, a process can be in running state or not running state.
- Running State − Indicates that the process is currently being executed by the CPU.
- Not Running State − Indicates that the process is not currently being executed. It can be in a waiting state or ready state.
This can be visualized as in the diagram below −
The diagram shows that when a new process is created, it is kept in the not running state until the CPU is allocated to it. Once the CPU is allocated, it moves to the running state. Sometime, if the process needs to wait for I/O operations or other resources, it goes back to the not running state.
The dispatcher is a special program that checks if the CPU is free and allocates it to a process from the not running state. Hence, the process of allocating CPU to a process is called dispatching.
Five State Model
The five-state model describes the lifecycle of a process in 5 stages. Here the not running state is further divided into three states - start, ready, and waiting. This can be visualized as in the diagram below −
- Start State − The start state is where a new process is created and initialized. The process is not yet ready to run.
- Ready State − In the ready state, the process is ready to run and is waiting for CPU allocation. It has all the necessary resources except the CPU.
- Running State − The running state indicates that the process is currently being executed by the CPU.
- Waiting State − The waiting state happens when a process is waiting for something like I/O operations or other resources. The process cannot continue execution until the user inputs data or the required resource becomes available.
- End State/Terminated State − The end state indicates that the process has completed its execution and is terminated from CPU.
Seven State Model
The seven-state model further breaks down the five states model by adding two additional states suspended ready and suspended blocked. This can be visualized as in the diagram below −
- Suspended Ready State − In this state, the process is in the ready state but has been suspended by the operating system. This can happen when the system needs to free up resources for other processes to avoid deadlock.
- Suspended Blocked State − In this state, the process is in the waiting state but has been suspended by the operating system. This can happen when the process is waiting for a resource that is not available, and the system needs to free up resources for other processes.
Conclusion
A process in an operating system undergoes various states during its lifecycle. The two-state, five-state, and seven-state models provide different levels of detail about the process states. The two state model is the simplest with only running and not running states. The five-state model adds more detail by breaking down the not running state into start, ready, waiting, and end states. The seven-state model further adds suspended ready and suspended blocked states.