Introduction

Process states define the various stages a process undergoes during its execution within an operating system. Understanding these states is critical for effective process management, scheduling, and resource allocation. Process state transitions reflect the dynamic behavior of processes and are fundamental to multitasking environments.

"A process is a program in execution and the process state represents its current activity and resource needs." -- Abraham Silberschatz

Process Concept

Definition

Process: an instance of a program in execution. Contains program code, current activity (Program Counter), stack, data section, and OS resources.

Components

PCB (Process Control Block): stores process state, program counter, CPU registers, memory limits, open files, and scheduling info.

Importance of States

States enable OS to manage process execution, facilitate scheduling, and coordinate resource sharing and synchronization.

Process Lifecycle

Lifecycle Overview

Lifecycle stages: New → Ready → Running → Waiting → Terminated, plus suspended variants. Cycle repeats until termination.

State Management

OS tracks state transitions via PCB updates. State changes occur on events: interrupts, I/O, scheduling decisions.

Multitasking Impact

Concurrency requires rapid transitions and context switches. States optimize CPU utilization and throughput.

New State

Definition

New: process is being created. Resources allocated, PCB initialized, program code loaded into memory.

Transition

On successful setup, process moves to Ready state. Failure leads to termination.

OS Actions

Assign unique PID, allocate memory, initialize registers, set up I/O descriptors.

Ready State

Definition

Ready: process prepared to execute, waiting for CPU allocation.

Queue Management

Ready queue holds processes in this state. Scheduling algorithms select next to run.

Preemption

Processes may be preempted back to Ready after running or if interrupted.

Running State

Definition

Running: process actively executing instructions on CPU.

Execution

CPU executes process instructions, updates program counter and registers.

Possible Transitions

May move to Waiting (I/O), Ready (preemption), or Terminated (completion).

Waiting State

Definition

Waiting (Blocked): process awaits event/resource, e.g., I/O completion, semaphore signal.

Event-driven

Process cannot proceed until awaited event occurs.

Transition

Upon event completion, process moves to Ready state.

Suspended States

Definition

Suspended: process swapped out of main memory to secondary storage, either Ready or Waiting suspended.

Suspended Ready

Process is ready but swapped out. OS swaps it back to main memory before Ready.

Suspended Waiting

Process blocked and swapped out. Swapped in when event occurs and process becomes Ready.

Process State Transitions

State Diagram

Transitions governed by events: creation, dispatch, interrupt, I/O request/completion, termination.

Transition Triggers

Dispatch: Ready → Running; Interrupt: Running → Ready; I/O request: Running → Waiting; I/O complete: Waiting → Ready; Termination: Running → Terminated.

Complex Transitions

Suspension and swapping add transitions: Ready ↔ Suspended Ready, Waiting ↔ Suspended Waiting.

Process Scheduling and States

Role of States

Scheduling algorithms select processes in Ready state for CPU allocation.

Scheduling Policies

FCFS, Round Robin, Priority, Multilevel Queue impact timing and fairness of state transitions.

State Influence

Process behavior in states affects scheduling efficiency, throughput, response time.

Context Switching and State Preservation

Definition

Context switch: saving state of running process and loading state of next Ready process.

State Preservation

Registers, program counter, stack pointer saved/restored in PCB.

Overhead

Context switch incurs CPU time overhead; efficient state management minimizes delays.

Save_State(process): PCB[process].PC ← CPU.PC PCB[process].Registers ← CPU.Registers PCB[process].Stack_Pointer ← CPU.Stack_Pointer PCB[process].State ← Ready or WaitingLoad_State(process): CPU.PC ← PCB[process].PC CPU.Registers ← PCB[process].Registers CPU.Stack_Pointer ← PCB[process].Stack_Pointer PCB[process].State ← Running

Summary Table of Process States

StateDescriptionTypical Transitions
NewProcess being created; resources allocated.New → Ready
ReadyPrepared to run; waiting for CPU.Ready → Running, Running → Ready
RunningExecuting instructions on CPU.Running → Waiting, Running → Ready, Running → Terminated
WaitingBlocked, awaiting event/resource.Waiting → Ready
Suspended ReadyReady but swapped out of memory.Suspended Ready → Ready
Suspended WaitingWaiting and swapped out.Suspended Waiting → Waiting → Ready
TerminatedProcess finished execution, resources freed.--

References

  • Silberschatz, A., Galvin, P. B., & Gagne, G. - Operating System Concepts - Wiley, 9th Ed., 2013, pp. 152-210.
  • Tanenbaum, A. S., & Bos, H. - Modern Operating Systems - Pearson, 4th Ed., 2015, pp. 180-240.
  • Stallings, W. - Operating Systems: Internals and Design Principles - Pearson, 9th Ed., 2018, pp. 120-175.
  • Arpaci-Dusseau, R. H., & Arpaci-Dusseau, A. C. - Operating Systems: Three Easy Pieces - Arpaci-Dusseau Books, 2018, pp. 45-95.
  • Love, R. - Linux Kernel Development - Addison-Wesley, 3rd Ed., 2010, pp. 85-130.