Chapter 8: Process Context — Who's Running Your Code
Vol 3: Computer Core Expedition · Chapter 8
Metadata Card
| Attribute | Value |
|---|---|
| Keywords | Process State Machine, Context Switching, Scheduling, PCB, fork/exec |
Your Progress
"A program on disk is inert. When you run it, the OS creates a process — an active entity with its own address space, file descriptors, and execution state."
Encounter 1: Process States
New → Ready → Running → Terminated
↕ ↓
Waiting ← I/OEncounter 2: PCB (Process Control Block)
Each process has a PCB containing:
- Process ID (PID)
- Register state (for context switching)
- Memory management info
- Open file descriptors
- Scheduling priority
Encounter 3: Context Switching
When the OS switches from one process to another:
- Save current process's registers to its PCB
- Load next process's registers from its PCB
- Flush TLB (if page tables differ)
- Resume execution of new process
Cost: 1-100 μs (thousands of CPU cycles)
Encounter 4: fork() and exec()
fork(): Creates a near-identical copy of the current processexec(): Replaces the current process's memory with a new program
Verification Checklist
- [ ] Can explain the process state machine
- [ ] Can describe what happens during a context switch
- [ ] Can explain the difference between fork() and exec()
→ Next Stop Preview
Chapter 9: Threads and Synchronization