Processes and the Process Control Block

College Depth 62 in the knowledge graph I know this Set as goal
Unlocks 109 downstream topics
process PCB program-counter address-space

Core Idea

A process is a program in execution — an active entity that includes the program code, current activity (program counter, registers), stack, heap, and data segment. The operating system represents each process with a Process Control Block (PCB), a data structure storing process state, PID, register values, memory maps, open file descriptors, and scheduling information. Multiple processes may run the same program but maintain separate address spaces, so they do not interfere with each other's data. The PCB is saved and restored during context switches.

How It's Best Learned

Inspect /proc/<pid>/ on Linux to see the live PCB-equivalent data. Write a fork() program and observe how parent and child diverge despite sharing the same code.

Common Misconceptions

Explainer

From your study of instruction set architecture, you know that a CPU executes a sequence of instructions, maintaining state in registers like the program counter (which instruction to execute next) and the stack pointer. A process is what happens when the operating system takes a passive program — a file sitting on disk — and brings it to life as an active, running entity with its own registers, memory, and system resources.

A process is more than just code. It encompasses the text segment (the compiled machine instructions), the data segment (global and static variables), the heap (dynamically allocated memory that grows upward), and the stack (function call frames, local variables, and return addresses that grows downward). Each process also maintains CPU state: the current values of all registers, the program counter pointing to the next instruction, and the processor status word. Together, these components define the complete execution context — everything needed to pause a process and resume it later exactly where it left off.

The operating system tracks all of this in a data structure called the Process Control Block (PCB). Every process has one. The PCB stores the process ID (PID), current process state (running, ready, waiting), saved register values, memory management information (page tables, segment limits), I/O status (open file descriptors, pending I/O operations), and scheduling data (priority, CPU time consumed). When the OS switches the CPU from one process to another — a context switch — it saves the running process's register values into its PCB, then loads the next process's saved registers from its PCB. The CPU seamlessly resumes the new process as if it had never stopped. This save-and-restore cycle is what enables multitasking: dozens of processes take turns on the CPU, each unaware of the others.

The critical insight is that processes are isolated by default. Two processes running the same program binary have completely separate address spaces — process A's variable `x` at virtual address 0x1000 and process B's variable `x` at virtual address 0x1000 refer to different physical memory locations. Neither can read or corrupt the other's data. This isolation is enforced by the hardware memory management unit, which the OS configures separately for each process. When processes do need to communicate, they must use explicit inter-process communication (IPC) mechanisms — pipes, shared memory segments, message queues, or sockets — that the OS mediates and controls.

Practice Questions 5 questions

Prerequisite Chain

Counting to 10Counting to 20Understanding ZeroThe Number ZeroCounting to FiveOne-to-One CorrespondenceCombining Small Groups Within 5Addition Within 10Addition Within 20Two-Digit Addition Without RegroupingTwo-Digit Addition with RegroupingAddition Within 100Repeated Addition as MultiplicationMultiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Two-Digit by One-Digit DivisionDivision with RemaindersRemainders and Quotients in DivisionDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueReading and Writing DecimalsComparing and Ordering DecimalsAdding and Subtracting DecimalsMultiplying DecimalsDividing DecimalsDividing FractionsMixed Number ArithmeticOrder of OperationsOperators and ExpressionsArithmetic Operators and Operator PrecedenceComparison Operators and Boolean TestsLogical Operators and Boolean AlgebraBoolean Algebra and Fundamental LawsCombinational Circuit DesignFlip-Flops and LatchesBinary Counters: Design and AnalysisBinary ArithmeticFixed-Point Number RepresentationTwo's Complement RepresentationOverflow and Underflow DetectionBinary Adders: Half-Adders and Full-AddersFull Adder and Carry PropagationCarry Lookahead Adder DesignHalf Adder Circuit DesignMultiplication Circuit DesignSequential Circuit DesignRegisters and Register FilesInstruction Set Architecture (ISA)Kernel Architecture and OS StructureSystem Calls and User/Kernel ModeProcesses and the Process Control Block

Longest path: 63 steps · 236 total prerequisite topics

Prerequisites (3)

Leads To (11)