← back to Operating Systems

Processes

Wikipedia · wpProcess (computing) · CC BY-SA 4.0

A process is a program in execution. The program is static code on disk. The process is the live instance: code plus current state, registers, open files, and a place in the scheduling queue.

Process vs program

A program is a passive file. A process is active. One program can spawn many processes (open two terminals running the same shell). Each process has its own address space, program counter, and stack. The operating system tracks all of this in a Process Control Block (PCB).

Process states

Every process moves through a lifecycle. The five-state model covers it: new, ready, running, waiting, terminated.

New Ready Running Waiting Terminated admit dispatch preempt I/O wait I/O done exit

Process Control Block

The PCB stores everything the OS needs to manage a process: PID, state, program counter, CPU registers, memory limits, list of open files, and scheduling priority. Context switching means saving one PCB and loading another.

Scheme

Context switching

When the OS switches from one process to another, it saves the entire CPU state (registers, program counter, stack pointer) into the outgoing PCB and loads the state from the incoming PCB. This is pure overhead. The faster you can do it, the more responsive the system feels. Hardware support (like special save/restore instructions) helps.

Scheme
Neighbors
  • 🔀 Turing Machines — abstract processes: a tape, a head, and a state machine
  • 💻 TOC Ch.5 — pushdown automata and stack machines: processes use a call stack that is a runtime instance of the pushdown automaton
  • 🪄 SICP Ch.8 — environments and closures: OS processes are isolated environments, analogous to lexical closures in a language
  • ⚙ Algorithms Ch.1 — asymptotic analysis: process creation and context-switch costs determine scheduling feasibility

Foundations (Wikipedia)