CS 152 Computer Architecture and Engineering
CS252A Graduate Computer Architecture Lecture 10 - Address Translation

Chris Fletcher
UC Berkeley, Spring 2026

Bare Machine

Why Dynamic Address Translation?

  1. Slow I/O → multiprogramming
    • CPU idle during programmed I/O; overlap one program's compute with another's I/O (DMA + interrupts)
    • Several programs + a resident OS in memory at once
  2. Location independence
    • Programs compiled for the same addresses must sit in different regions
    • Need a base register: run from any physical start without relinking
  3. Protection
    • A bug in one program must not corrupt others or the OS
    • Need a bound register

Multiprogramming needs resident supervisor software (the OS) to switch programs and set up translation.

Check Your Understanding

1. In a bare machine, which software tools placed location-independent library modules at fixed physical addresses?
The linker or loader, by static relocation.
2. What problem motivated keeping several programs in memory, and which two registers made it safe and flexible?
Slow I/O left the CPU idle, motivating multiprogramming. Base register: location independence. Bound register: protection.

Simple Base and Bound Translation

Logical addr X Bound reg ≥ Boundsviolation Base reg + Physical address
  • Program runs in its own address space starting at 0 (logical addresses)
  • Logical ≥ bound (segment length) → bounds violation
  • In parallel: physical = base + logical
  • Base and bound are visible only in supervisor mode

$\text{Physical Address} = \text{Base} + \text{Logical Address}$

Separate Program and Data Segments

Base and Bound in the Pipeline

Fragmentation with Segments

start Job 1 (32K) Job 2 (24K) free 72K Job 3 arrives Job 1 Job 2 Job 3 (64K) 8K Job 2 leaves Job 1 24K hole Job 3 8K Job 4 (32K)? 32K free,no 32K hole 128K memory
  • External: enough total free memory, but no contiguous hole big enough
    • OS must compact (copy Job 3 up): expensive
  • Internal: a job uses its low and high addresses but not the middle; the contiguous segment wastes the gap

Check Your Understanding

1. Base = 0x4000, bound = 0x1000. What happens on a load at logical 0x1000? At 0x0500?
0x1000 ≥ 0x1000: bounds violation. 0x0500: passes, physical = 0x4500.
2. Explain external vs. internal fragmentation with segments.
External: enough free memory in total, but split into holes too small for the segment. Internal: unused addresses inside an allocated segment between its low and high used addresses.

Paged Memory Systems

Virtual address = [ Page number | Offset ]

  • Fixed-size pages in both virtual and physical memory
  • Offset passes through unchanged
  • Page number indexes the page table → physical page
  • Large contiguous virtual space on non-contiguous physical pages
Job 1 VAPage tablePhysical 0123 VP1VP0VP3VP2

Private Address Space per User

Page Tables Live in Memory

Size of a Linear Page Table

32-bit VA, 4 KB pages, 4 B PTE64-bit VA, 1 MB pages, 8 B PTE
Offset bits1220
PTEs$2^{20}$$2^{44}$
Table size per process$2^{20} \times 4 = $ 4 MB$2^{44} \times 8 = 2^{47}$ = 128 TiB

Check Your Understanding

1. 32-bit VA, 8 KB pages, 4-byte PTEs. Linear page table size per process?
Offset 13 bits → $2^{19}$ PTEs × 4 B = $2^{21}$ B = 2 MB.
2. Why not fix the 64-bit page table explosion with multi-megabyte pages?
Severe internal fragmentation and a much larger page-fault penalty.

Hierarchical Page Tables

RISC-V Sv32 p1 [31:22] — 10 bits p2 [21:12] — 10 bits offset [11:0] — 12 bits

Three-Level Walk: SPARC v8

Index 1 [31:24] Index 2 [23:18] Index 3 [17:12] Offset [11:0]

Translation-Lookaside Buffers (TLB)

VRWDtag (VPN)PPN

TLB Designs and TLB Reach

$\text{TLB Reach} = \text{entries} \times \text{page size}$

Handling a TLB Miss

Software-managed (MIPS, Alpha)Hardware-managed (SPARC v8, x86, PowerPC, RISC-V)
Who walksOS exception handler, in untranslated modeMMU page-table walker from satp
PipelineException flushes the pipeline: costly on OoO superscalarsRefills without a flush
Page missingHandler deals with itWalker gives up and raises a page fault

Check Your Understanding

1. Two-level table (10/10/12). Why does a program using 8 KB of code and 8 KB of stack not need 4 MB of page table?
L1 entries for unused 4 MB regions are nonexistent; L2 tables exist only for the regions in use.
2. TLB reach for 128 entries and 8 KB pages?
128 × 8 KB = 1 MB.