Paging & Page Tables
Paging turns memory into fixed-size pages and frames. The page table is the map, and the offset is the part that never changes.
In plain English
Paging cuts memory into equal pages and frames. The page table is the map from page to frame.
By the end you will be able to
- Explain pages, frames, and page-table entries.
- Split a virtual address into page number and offset.
- Translate a virtual address through a page table.
- Know what present and protection bits mean.
Pages and frames
Virtual memory is divided into fixed-size pages; physical memory is divided into frames of the same size. A page can be placed in any free frame. The page table maps each virtual page number to a frame number. Because pages are fixed-size, there is no external fragmentation; only the last page of a process may be partially wasted.
The address split
A virtual address has two parts: the virtual page number and the offset. With 4 KB pages, the offset is 12 bits because 2^12 = 4096. The page number indexes the page table; the offset selects a byte inside the page. The physical address is the frame number times the page size plus the offset.
page_size = 4096
vaddr = 0x1A2B
vpn = 0x1A2B / 0x1000 = 1
offset = 0x1A2B % 0x1000 = 0xA2B
frame = page_table[1] = 7
paddr = 7 * 0x1000 + 0xA2B = 0x7A2BPage-table entries
A page-table entry stores the frame number plus control bits. The present/valid bit says whether the page is in memory. Protection bits say read, write, execute, or user/kernel access. A dirty bit says the page has been modified, and a reference bit helps replacement policies. A missing page triggers a page fault, which is the bridge to virtual memory.
Watch it happen
Step through the worked example. Play it, pause it, or move one step at a time.
step-by-step
Step 1 of 4
Start with the virtual address
The CPU generates virtual address 0x1A2B.
page size = 4096 bytes = 0x1000
Key takeaways
- Pages are virtual; frames are physical.
- The virtual address splits into page number and offset.
- The page table maps page number to frame number.
- The offset is unchanged during translation.
- Present and protection bits control access and faults.
Common pitfalls
- Adding the page number to the offset instead of the frame base.
- Forgetting that the offset width comes from the page size.
- Assuming the page table itself is always in physical memory.
Kernel notes
- Compute the offset width from the page size.
- Translate a virtual address step by step.
- Explain the present and dirty bits.
Quick check
1. With 4 KB pages, what is the offset for virtual address 0x1A2B?
2. What does the present bit in a page-table entry indicate?