Why is a single-level page table wasteful for a 32-bit space?
It needs one PTE per virtual page (220 entries = 4MB per process) even though most pages are unused.
Size formula for a single-level table?
2V−p×E bytes, where V=addr bits, p=log2(page size), E=PTE size.
Why does multi-level save space?
Unused regions are a single "not present" entry in the directory, so their second-level tables are never allocated (sparsity → savings).
How do you split a virtual address for k levels?
Add the bits: V=(L1 bits)+⋯+(Lk bits)+p (offset).
Why choose 10/10/12 for 32-bit, 4KB, 4B PTE?
So each second-level table (1024×4B = 4KB) fits exactly in one page; remaining bits go to directory and offset.
Time cost of a k-level table per memory reference?
k+1 accesses (k for the walk, 1 for the data) — without a TLB.
What hardware hides the walk cost?
The TLB, which caches VPN→PFN; a hit skips the page-table walk.
Worst-case space vs single-level?
Slightly larger — you add directory page(s) on top of all leaf tables; multi-level only wins when sparse.
EAT formula with TLB hit rate h?
h(tTLB+tmem)+(1−h)((k+1)tmem+tTLB).
Recall Feynman: explain to a 12-year-old
Imagine a giant hotel with a million rooms, and one huge guest list with a line for every room — even empty ones. That list is enormous and mostly blank. Instead, we keep a small floor directory: "Floor 3 has guests, here's its list; Floor 4 is empty — no list at all." To find a person you check the floor directory, then that floor's small list. You only keep lists for floors that actually have people. Looking someone up takes a couple of extra steps, so we keep a sticky-note (the TLB) of the people we looked up recently to go faster.
Dekho, problem yeh hai: ek 32-bit process ke paas 4GB virtual space hota hai. Agar hum ek hi flat page table banayein, toh har page ke liye ek entry chahiye — total 220 entries, yaani 4MB sirf table ke liye, har process ke liye! Aur sach yeh hai ki process apne space ka bahut chhota hissa hi use karta hai, baaki table khaali padi rehti hai. Yeh memory ka waste hai.
Multi-level page table is waste ko khatam karta hai. Hum virtual address ke bits ko todte hain: upar ke bits directory (L1) ko index karte hain, beech ke bits second-level table (L2) ko, aur neeche ke bits offset hote hain. Agar koi region use hi nahi ho raha, toh directory mein bas "not present" likh do — uska L2 table banane ki zaroorat hi nahi. Isi sparsity se memory bachti hai. 32-bit ke liye split hota hai 10+10+12, taaki har L2 table exactly ek 4KB page mein fit ho jaye.
Lekin har cheez free nahi hoti. Ab ek address translate karne ke liye 2 extra memory reads lagte hain (L1, L2), phir actual data read — total 3 accesses ek ke badle. Yeh time overhead hai. Iska solution hai TLB: yeh recent translations ka cache hai. Agar TLB hit ho gaya, toh walk skip ho jaata hai aur speed wapas aa jaati hai. Isiliye locality important hai — agar program same pages baar-baar touch karta hai, TLB hit rate high rehta hai aur overhead almost zero ho jaata hai.
Yaad rakho: multi-level space bachata hai sirf jab table sparse ho. Agar pura space use ho, toh thoda zyada memory lagti hai (extra directory). Real life mein space hamesha sparse hota hai, isliye yeh approach jeet jaati hai — x86-64 toh 4 levels use karta hai!