Professional Documents
Culture Documents
Virtual Memory and Demand Paging
Virtual Memory and Demand Paging
Demand Paging
virtual-to-physical
translations
1
Virtual Address Translation
29 virtual address 13
0
Example: typical 32-bit 00 VPN offset
architecture with 8KB pages.
physical address
{ PFN +
offset
2
The Translation Lookaside Buffer (TLB)
CPU
TLB Control
MMU
Memory
3
Completing a VM Reference
MMU access
probe load
start page table TLB physical
here memory
load
zero-fill
TLB OS
4
Alpha Page Tables (Forward Mapped)
21 L1 L2 L3 PO
seg 0/1 10 10 10 13
+
three-level page table
offset at each level is (forward-mapped)
determined by specific bits in VA
PFN
PFN
5
Paged Virtual Memory
6
Where Pages Come From
file volume
Modified (dirty)
with pages are pushed to
executable programs backing store (swap)
text on eviction.
data
BSS
user stack
args/env
kernel
Fetches for clean text Paged-out pages are
or data are typically fetched from backing
fill-from-file. store when needed.
Initial references to user
stack and BSS are satisfied
by zero-fill on demand.
7
Issues for Paged Memory Management
file volume
Modified (dirty)
with pages are pushed to
executable programs backing store (swap)
text on eviction.
data
BSS
user stack
args/env
kernel
Fetches for clean text Paged-out pages are
or data are typically fetched from backing
fill-from-file. store when needed.
Initial references to user
stack and BSS are satisfied
by zero-fill on demand.
8
Questions for Paged Virtual Memory
memory putpage
objects getpage
pmap_page_protect
pmap pmap_clear_modify
pmap_is_modified
pmap_is_referenced
pmap_enter()
pmap_clear_reference
pmap_remove()
page cells (vm_page_t)
array indexed by PFN
One pmap (physical map) system-wide
per virtual address space. page table phys-virtual map
9
Mapped Files
10
CPS 210
Memory Objects
Memory objects “virtualize” VM backing
storage policy.
object->putpage(page)
• source and sink for pages object->getpage(offset, page, mode)
triggered by faults
...or OS eviction policy memory object
• manage their own storage
• external pager has some control:
prefetch swap vnode extern
pager pager pager
prewrite
protect/enable
anonymous VM mapped files DSM
• can be shared via vm_map() databases
reliable VM
(Mach extended mmap syscall) etc.
CPS 210
The Block/Page I/O Subsystem
11
Shadow Objects and Copy-on-Write
A Copy-on-Write Mapping
Warning: this is a fictional diagram intended to
be representative only; any similarity to any specific
system is purely coincidental.
shadow shadow
12