CS 152 Computer Architecture and Engineering CS252A Graduate Computer Architecture
Lecture 11 - Virtual Memory and Caches
Chris Fletcher UC Berkeley, Spring 2026
Modern Virtual Memory Systems
Illusion of a large, private, uniform store
Protection & privacy
Each process has a private address space (plus shared ones)
Page table ≡ name space
Demand paging
DRAM as a software-managed cache for disk
Run programs larger than physical memory; hide differences in memory configuration
Address Translation: Putting It All Together
Page-Fault Handler
Find the missing page on disk (or create a fresh zero-filled page)
No free frame? Pick a victim to swap out
Often pseudo-LRU in software; OS may keep a free-page pool in the background
Read the page from disk, update the page table
Disk takes milliseconds (millions of cycles): always handled in software, untranslated mode
OS saves the faulting job's context and runs another job meanwhile
VM Exceptions in the Pipeline
I-TLB (fetch) and D-TLB (memory) can raise TLB miss, page fault, protection violation
Need restartable exceptions: resume after the OS brings the page in
Imprecise restartable is possible but complicates the OS
Precise exceptions make restart straightforward
TLB is now in series with the cache. Options:
Slow the clock (unacceptable)
Pipeline TLB + cache (raises branch and load-use latency)
Virtual-address caches
Parallel TLB/cache access
Check Your Understanding
1. Why are TLB misses sometimes handled in hardware but page faults always in software?
A TLB miss walks tables in DRAM (tens of ns), fast in hardware without a flush. A page fault reads disk (ms, millions of cycles): software overhead is negligible and the OS can switch jobs.
2. Why must a page fault be restartable?
The faulting instruction hasn't accessed its data; after the OS loads the page and updates the table, it must re-execute from the start.
Virtual-Address Caches (VIVT)
CPU →VA Virtual cache →VA TLB →PA Memory (e.g., StrongARM)
Translate only on a miss
(+) One-step on a hit
(−) Context switch: flush, unless tags include an ASID
Each way = 64 sets × 64 B = 4 KB (one page): the rule fixes the way size, not a power-of-2 way count. 12 lines spaced 4 KB apart hit in L1 (4 cycles); 14 spill to L2 (~14 cycles).
Anti-Aliasing Using an Inclusive L2
Want a big low-associativity L1 ($L + b > k$) or a VIVT L1? L2 inclusive of both L1s
MIPS R10000 (1996), VIPT L1:
VA1 cached in L1 at virtual index bits a1; L2 (physically indexed/tagged) stores a1 in its tag: [PA | a1 | data]
2. In the R10000 scheme, why does L2 store the a1 bits in its tag?
When VA2 misses L1 and hits PA in L2, L2 needs a1 to detect the index mismatch and find VA1's L1 set to purge it.
VM Features Track Historical Uses
Era
Mechanism
Bare machine
Physical addresses only; one program owns the machine
Batch multiprogramming
Base & bound: translation + protection, whole-program swapping; external fragmentation
Time sharing
Fixed-size pages (no external fragmentation) + demand paging (only working sets resident)
Virtual machine monitors
Two levels: guest virtual → guest physical → host physical (1970s IBM; now clouds, laptops)
Virtual Memory Use Today
Domain
VM support
Why
Servers, desktops, laptops, phones
Full demand-paged VM
Portability, isolation, sharing DRAM, simpler OS
Vector supercomputers, GPUs
Translation + protection, rarely demand paging
Can't waste compute thrashing to disk; restartable vector exceptions are hard
Embedded, DSPs
Physical addresses only
No area/power for TLBs; often no disk; fixed memory map; exposed pipelines
Older Crays used base & bound; Japanese supercomputers and Cray X1/X2 used pages.
Check Your Understanding
1. Why do GPUs and vector supercomputers implement translation and protection without full demand paging?
Jobs are sized to fit in memory so expensive compute doesn't sit idle thrashing to disk, and precise restartable exceptions for wide vector instructions are very hard.
← → / space to move · A to reveal answers · F fullscreen