Addressing Page Tables
Physical Page Tables: Set a predefined portion of physical ram for kernel page tables
- Inflexible - Page tables cannot be swapped
- Simple - Hardware support easy to impl
Kernel Virtual Memory: Use page tables to store kernel page tables
- Need to keep special code & data (e.g. outer PT, fault handlers) in physical memory
Managing Swap Space
- Use a raw disk partition: Faster, require disk formatting to resize
- Use a file in fs: Slower, more flexible to resize
Virtual Memory Area
VMA: A description of each address space region (e.g. shared libraries)
- Example Info: read/write/execute/shared/locked, name
- Linked list
- mmap/malloc creates a new VMA
MMap: Map a file to a memory region, synchronous read/write
Segfault: On page faults, check VMA first to verify if the address is valid
Ensuring Fairness
Space Fairness
Replacement
- Local Replacement: Evict each process’ own pages when full
- Global Replacement: One process can evict other processes’ pages
Sharing
Sharing pages: Put the same PTE in another process’ PT (with different permissions)
- Must update both PTE during page swapping
- Process shouldn’t store their pointers in the shared area (invalid for other processes)
Copy on Write: Avoid copying as long as possible, create shared mapping instead
- Read-only for both parent and child in fork(), copy when protection fault is triggered