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

To manage this behavior efficiently, the operating system models a process as being in different states at different times.
This concept originated in early operating systems and remains fundamental today.


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:

TimeProcess 0Process 1Notes
1RunningReady
2RunningReady
3RunningReady
4RunningReadyProcess 0 finishes
5Running
6Running
7Running
8RunningProcess 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:

TimeProcess 0Process 1Notes
1RunningReady
2RunningReady
3RunningReadyProcess 0 initiates I/O
4BlockedRunningProcess 1 uses CPU
5BlockedRunning
6BlockedRunning
7ReadyRunningI/O completes
8ReadyRunningProcess 1 finishes
9Running
10RunningProcess 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:

  1. New

    • Process is being created

  2. Ready

    • Waiting for CPU

  3. Running

    • Executing on CPU

  4. Waiting (Blocked)

    • Waiting for I/O or event

  5. 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

Popular posts from this blog

Operating Systems OS PCCST403 Semester 4 BTech KTU CS 2024 Scheme

Introduction to Operating System -Virtualization, Concurrency, and Persistence

Differences Between Linux and Classic UNIX Kernels