Page Tables
You'll learn how page tables act as the "phone book" that translates virtual addresses into physical addresses in a paging system.
What is a Page Table?
A page table is a data structure maintained by the operating system that maps virtual page numbers (VPN) to physical frame numbers (PFN). When a program uses a virtual address, the MMU consults the page table to find where that page actually lives in physical memory.
Think of it like a building directory: your apartment number (virtual page) tells you nothing about the building's physical layout. The directory maps your apartment number to an actual floor and location (physical frame).
How Page Tables Work
Each process has its own page table. When the CPU generates a virtual address, it's split into two parts:
- Virtual Page Number (VPN): Used as an index into the page table
- Offset: Position within the page (stays the same in translation)
The page table entry at index VPN contains the corresponding physical frame number. The MMU combines this frame number with the original offset to produce the complete physical address.
What's in a Page Table Entry?
Each entry typically stores:
- The physical frame number where the page resides
- Status bits like valid/invalid, present/absent, read/write permissions
- Additional metadata for memory protection
The page table bridges the gap between what your program sees (virtual addresses) and what actually exists in RAM (physical frames).
Key Takeaway: Page tables are per-process data structures that map virtual page numbers to physical frame numbers, enabling address translation and making virtual memory work.