Modern 64-bit CPUs do not use flat arrays for page tables (which would require 512GB of RAM just to store the page table!). Instead, Linux utilizes a 4-Level hierarchical page table (PGD -> P4D -> PUD -> PMD -> PTE) where page table pages are allocated on demand only for active virtual address ranges.
Visual representation of control loops, memory layout, and execution flow for Main Memory Management, Paging & Segmentation.
A Virtual Address of $m$ bits is split into a Page Number ($p$ bits) and an Offset ($d$ bits). For a 4KB page ($2^{12}$ bytes), the offset $d$ is 12 bits.
The hardware Memory Management Unit (MMU) uses page number $p$ as an index into the process Page Table (stored in RAM at address CR3) to retrieve physical Frame Number $f$.
The physical address is constructed by concatenating Frame Number $f$ with the original Offset $d$ ($Address_{physical} = f \times 2^{12} + d$).
To avoid massive contiguous page table overhead in 64-bit systems, page tables are structured hierarchically (e.g., 4-level or 5-level paging), keeping unused address subtrees unallocated.
| Feature / Dimension | Paging | Segmentation |
|---|---|---|
| Block Size & Boundaries | Fixed-size physical blocks (e.g., 4KB, 2MB Huge Pages) determined by hardware architecture. | Variable-size logical blocks (Code, Stack, Heap, Global segment) reflecting programmer modules. |
| Fragmentation Type | Suffers only from minor Internal Fragmentation; ZERO External Fragmentation. | Suffers from severe External Fragmentation (requires dynamic compaction). |
| Hardware / OS Role | Transparent to programmer; handled entirely by hardware MMU and OS page tables. | Visible logically to compiler/programmer (Segment base + Segment limit). |
| Modern Adoption | Universal standard used by all modern 64-bit x86 and ARM processors. | Largely deprecated/flattened in 64-bit mode (used mostly for thread-local storage FS/GS registers). |
Detailed answers, interviewer pro tips, key takeaway summaries, and code examples formulated for technical rounds.
✅ Correction: The Page Number ($p$) determines which page table entry to look up for the frame address. The Offset ($d$) represents the exact byte location within that 4KB page and is copied directly without modification from virtual to physical address.
Paging maps fixed-size virtual pages ($2^d$ bytes) to identical physical frames in RAM via Page Tables.