Process States in Operating Systems
Process States in Operating Systems
1. Why Do We Need Process States?
A process does not execute continuously from start to finish. During its lifetime, it may:
-
Compete for the CPU
-
Wait for I/O operations
-
Be temporarily paused by the operating system
2. Basic Process States (Simplified Model)
In a simplified view , a process can be in one of three states:
1. Running
-
The process is currently executing instructions on the CPU
-
At any instant, only one process per CPU can be in the running state
📌 Example:
A program actively performing calculations on the processor.
2. Ready
-
The process is ready to run
-
It has everything it needs except the CPU
-
The OS may delay it because another process is currently running
📌 Example:
A text editor waiting its turn while a browser is using the CPU.
3. Blocked (or Waiting)
-
The process cannot run until some external event occurs
-
Most commonly waiting for I/O completion
📌 Example:
A process waiting for data to be read from disk or received from the network.
3. Process State Transitions
Processes move between states as shown below:
Important Transitions:
-
Scheduled: Ready → Running
(The OS scheduler selects the process) -
Descheduled: Running → Ready
(Time slice expired or higher-priority process arrived) -
Block: Running → Blocked
(Process requests I/O or waits for an event) -
Wake-up: Blocked → Ready
(I/O completes or event occurs)
These transitions are entirely controlled by the operating system scheduler.
4. Example 1: CPU-Bound Processes (No I/O)
Consider two CPU-only processes:
| Time | Process 0 | Process 1 | Notes |
|---|---|---|---|
| 1 | Running | Ready | |
| 2 | Running | Ready | |
| 3 | Running | Ready | |
| 4 | Running | Ready | Process 0 finishes |
| 5 | – | Running | |
| 6 | – | Running | |
| 7 | – | Running | |
| 8 | – | Running | Process 1 finishes |
🔍 Observation:
-
Processes alternate based on scheduling
-
No blocking occurs because there is no I/O
5. Example 2: CPU + I/O Behavior
Now consider one process performing I/O:
| Time | Process 0 | Process 1 | Notes |
|---|---|---|---|
| 1 | Running | Ready | |
| 2 | Running | Ready | |
| 3 | Running | Ready | Process 0 initiates I/O |
| 4 | Blocked | Running | Process 1 uses CPU |
| 5 | Blocked | Running | |
| 6 | Blocked | Running | |
| 7 | Ready | Running | I/O completes |
| 8 | Ready | Running | Process 1 finishes |
| 9 | Running | – | |
| 10 | Running | – | Process 0 finishes |
🔍 Key Insight:
-
Blocking allows better CPU utilization
-
The OS keeps the CPU busy by switching to another ready process
6. Scheduler Decisions and Trade-offs
Even in this simple example, the OS must make key decisions:
-
Should it run another process while one is blocked? ✔️ Yes
-
Should it immediately switch back when I/O completes? ❓ Depends
These decisions are governed by scheduling policies, which aim to optimize:
-
CPU utilization
-
Throughput
-
Response time
-
Fairness
7. Process States (Extended Model)
Silberschatz extends the basic model to include additional states:
Common Five-State Model:
-
New
-
Process is being created
-
-
Ready
-
Waiting for CPU
-
-
Running
-
Executing on CPU
-
-
Waiting (Blocked)
-
Waiting for I/O or event
-
-
Terminated
-
Finished execution
-
📌 This model is more realistic and commonly used in textbooks and OS diagrams.
8. PCB and Process States (Silberschatz View)
The OS keeps track of process states using a Process Control Block (PCB), which contains:
-
Process state
-
Program counter
-
CPU registers
-
Memory management information
-
I/O status
-
Scheduling information
When a context switch occurs:
-
State of the running process is saved in its PCB
-
State of the next process is restored
9. Summary
-
A process moves through different states during execution
-
Running: executing on CPU
-
Ready: waiting for CPU
-
Blocked: waiting for I/O or event
-
OS uses state transitions to manage concurrency
-
Blocking improves CPU utilization
-
Scheduling decisions are critical for performance
-
Silberschatz extends the model with New and Terminated states and introduces PCB
Key Takeaway
Process states allow the operating system to efficiently manage CPU sharing, I/O waiting, and multitasking.


Comments
Post a Comment