Big idea
Every address a program uses is a virtual address. The program has no idea where data lives in physical memory — only the OS (with hardware help) does.
Starting assumptions
1. Address spaces are laid out contiguously in physical memory 2. Each address space is smaller than physical memory 3. All address spaces are the same size
Transparency
Relocation should be seamless: the process behaves as if it talks to hardware directly. That needs hardware support, not just OS software.
Example mental model
A small C snippet like x = x + 3 becomes loads/stores through registers (eax, ebx, etc.). The process might “think” it owns 16 KB: code near the bottom, heap growing up, stack growing down, free space in the middle — classic layout.
Dynamic relocation: base and bounds
Hardware keeps a base (physical start / offset) and bounds (size or limit) per process.
`` physical address = virtual address + base ``
Because this happens at runtime, it is dynamic relocation. The MMU holds the registers; on a context switch their values are saved in the PCB.
Bounds can be checked as “virtual address within size” or “physical address within limit” — both are valid framings.
Other pieces
- A free list tracks which equal-sized chunks of physical memory are available.
- Need user vs privileged mode, exceptions for out-of-bounds / bad permissions, and privileged updates to base/bounds.
Limitation
Base-and-bounds wastes space when the unused hole between heap and stack is large — internal fragmentation. That motivates segmentation next.