Menu

Earn Premium with Referrals

Invite your friends and earn Premium rewards through our referral program.

See how it works and start inviting friends.

Process Management & States
OS

Process Management & States

Master the basics of processes, the PCB, and the fascinating process life cycle.

A process is a program in execution — an active entity with a program counter, stack, data section, and resources. While a program is passive (a file on disk), a process is the realization of that program loaded into memory and executing on the CPU.

Process vs Program

AspectProgramProcess
NaturePassive (file on disk)Active (loaded in memory, executing)
LifespanPermanent until deletedFrom creation to termination
ResourcesNone (just occupies disk space)CPU, memory, I/O, file handles
RelationshipOne program can spawn many processese.g., opening 3 Chrome tabs = 3 processes
StorageStatic on diskDynamic in RAM + CPU registers

Process Control Block (PCB)

The OS maintains a PCB for every process. It’s the data structure that represents the process internally.

FieldDescription
Process ID (PID)Unique numeric identifier
Process stateCurrent state: new, ready, running, waiting, terminated
Program counterAddress of the next instruction to execute
CPU registersSaved during context switch (accumulators, index registers, stack pointer)
Scheduling infoPriority, queue pointers
Memory infoPage tables / segment tables
I/O statusList of open files, allocated devices

Process States

New → Ready → Running → Terminated
            ↕ Wait (I/O)
        Ready ↔ Running ↔ Wait
  • New — process being created
  • Ready — in memory, waiting for CPU allocation
  • Running — currently executing on CPU
  • Waiting (Blocked) — waiting for I/O, signal, or event
  • Terminated — finished execution, PCB still exists until parent reads exit status

Zombie & Orphan

  • Zombie: process terminated but PCB not yet cleaned up (parent hasn’t called wait())
  • Orphan: parent terminated before child — adopted by init (PID 1)

Context Switching

The CPU switches between processes by saving the current process’s state into its PCB and loading the next process’s state from its PCB. Context switching is pure overhead — no useful work is done during the switch.

Q: What are the five states of a process?

A: New (being created), Ready (waiting for CPU), Running (executing), Waiting (blocked for I/O/event), Terminated (finished). Ready and Waiting are most common — a process typically alternates between them.

Q: What information is stored in a PCB?

A: PID, process state, program counter, CPU registers (saved during context switch), scheduling priority, memory management info (page tables), and I/O status (open files, devices).

Q: Is a process the same as a program?

A: No. A program is a passive set of instructions on disk. A process is an active instance loaded in memory with its own execution context. One program can spawn multiple processes.

Q: What are zombie and orphan processes?

A: A zombie has finished executing but still has an entry in the process table because the parent hasn’t read its exit status. An orphan’s parent terminated before it — the kernel re-parents orphans to init (PID 1).

Q: Why is context switching considered overhead?

A: During a switch, the CPU saves/loads registers and flushes caches but executes zero user code. High switching frequency degrades throughput.

My Private Notes

Notes are auto-saved locally to this device.