Notes › Process Management
Process Management

Process Management Notes

Curated infographic guide for process concepts, PCB structure, state models, and threads.

Process & Memory Structure

What is a Process?
A Process is a program in execution. A program is passive (just code on disk), whereas a process is active, possessing resources like registers, buffers, and memory address spaces.

Address Space Sections:
  • Text — The executable code.
  • Data — Global and static variables.
  • Heap — Dynamically allocated memory during runtime (malloc / new). Grows upwards.
  • Stack — Local variables, function arguments, return addresses. Grows downwards.
Memory Trick: Heap is like a stack of building blocks built from the floor up (dynamic growth), while Stack is like a pile of plates descending from the ceiling. They grow towards each other. If they meet, you get a Stack Overflow!

The 5-State Process Model

A process moves through various states during its lifecycle:

NEW
READY
RUNNING
TERMINATED
WAITING / BLOCKED (from Running via wait; to Ready via I/O completion)
Transitions Explained
  • Admitted: Process creation completed, moved to ready queue.
  • Scheduler Dispatch: CPU scheduler picks the process to run.
  • Interrupt: Quantum time slice expires, yielding CPU back to Ready state.
  • I/O or Event Wait: Process requests resource or I/O, yielding CPU to wait.
  • I/O or Event Completion: Event finishes, process goes back to Ready to await CPU.

Process Control Block (PCB)

PCB Structure
The OS maintains a Process Control Block (PCB) for each process. This is the repository of all information needed to track and schedule the process.

PCB Contents:
  1. Process ID (PID): Unique identifier.
  2. Process State: New, Ready, Running, etc.
  3. Program Counter (PC): Pointer to the next instruction to run.
  4. CPU Registers: Register state to load during Context Switching.
  5. Memory Management: Page/Segment tables, limit registers.
  6. Accounting & I/O: Open file descriptors, allocated resources.

Processes vs Threads

  • Failure Impact
  • Characteristic Process Thread (LWP)
    Memory SpaceSeparate address space per processShared address space (code, data, resources)
    Creation OverheadHeavyweight (system calls, copy descriptors)Lightweight (shares resources, cheap stack creation)
    CommunicationRequires IPC (Pipes, Shared Memory, Sockets)Trivial (can write to shared global variables directly)
    Protected (one crash does not affect others)Shared (one thread crash can take down whole process)
    Context SwitchSlow (page table swap, TLB flush)Very fast (only register swap, keeps same page table)
    Practice Now