Exercises — Page tables and multi-level paging
Before we start, one shared picture. Every virtual address in these problems is a row of bits cut into named fields — the blue and yellow blocks together form the VPN, and the green block is the offset that rides through untouched. We reference this picture directly in Solutions 2.1 and 2.2, so study it now.

L1 — Recognition
Problem 1.1
A system has -bit virtual addresses and page size . State (offset bits), (VPN bits), and the number of entries a flat page table would need.
Recall Solution 1.1
WHAT we compute: the field widths, then the table length. WHY: bytes. The number of bits to name a byte inside one page is exactly of how many bytes it holds: The rest of the address names the page: A flat table has one entry per possible page, i.e. one per VPN value: Answer: , , entries .
Problem 1.2
Match each item to what it stores: (a) the index into a page table, (b) a page table entry (PTE).
Recall Solution 1.2
WHAT/WHY: The parent's rule "position is the key, entry is the value" decides this.
- (a) The index is the VPN (or the slice of VPN for that level) — it is implied by position, it stores nothing itself.
- (b) The PTE stores the PFN + flags (valid, read/write, user/supervisor, dirty, accessed). Answer: index ↔ virtual page number (positional); PTE ↔ physical frame number + flags.
L2 — Application
Problem 2.1
, . For virtual address 0x00003FFF, compute the offset and the VPN.
Recall Solution 2.1
WHAT: split the address at bit — exactly the green/coloured boundary in the shared picture (figure s01).
WHY offset first: the low bits are the offset (the green block); masking them off leaves the VPN (the blue+yellow blocks). See Bit Manipulation and Masking.
Recall from the symbol list that keeps the remainder and keeps the whole-number quotient:
0x00003FFF = 0x3 * 0x1000 + 0xFFF, so offset (the remainder).
Here (shift right by 12, from the symbol list) drops the 12 offset bits off the right end — the exact undo of building the address with .
Answer: offset , VPN .
Problem 2.2
Same system. Two-level split 10 / 10 / 12 ( = top 10 bits, = next 10, offset = 12). For virtual address 0x00801234, find , , offset. If L2[i2].PFN = 0x000AB, give the final physical address.
Recall Solution 2.2
WHAT: carve the address into three fields — literally the blue , yellow , green offset blocks of the shared picture (figure s01) — then reassemble the physical address.
Write the address in binary. 0x00801234:
Offset = low 12 bits = 0001 0010 0011 0100... take the last 12: 0010 0011 0100 .
WHY: , so 12 low bits ride through unchanged.
The remaining top 20 bits are 0000 0000 1000 0000 0001 .
Split those 20 bits into (top 10) and (next 10):
- top 10:
0000 0000 10, so . - next 10:
00 0000 0001, so . Final PA: glue the delivered PFN to the untouched offset: Answer: , , offset , PA .

L3 — Analysis
Problem 3.1
For , , a flat table uses 4 MiB (with 4-byte PTEs). Explain why the 10/10/12 two-level split makes each table exactly one page — and show the arithmetic.
Recall Solution 3.1
WHAT: count entries per table and multiply by PTE size. Each 10-bit index selects one of entries. With 4-byte PTEs: WHY this is elegant: a table that is exactly one page can itself be paged, allocated, and swapped by the very same machinery it describes — no special "big region" is needed. The 10/10/12 numbers are chosen precisely so . Answer: each level's table = one page.
Problem 3.2
A process uses exactly one code page and one stack page, far apart in the address space. Compute the total page-table memory for (a) flat, (b) two-level 10/10/12. State why they differ.
Recall Solution 3.2
WHAT: sum the tables actually allocated. (a) Flat: the table is fixed-size regardless of usage: (b) Two-level: you always need the one top table (4 KiB). Code and stack are "far apart," so they fall under different top-level entries ⇒ two inner tables (4 KiB each): WHY they differ: the flat table pre-reserves a slot for all pages even though almost all are untouched. Concretely: the top table has slots; the process uses only of them, leaving unused top-level slots. Each of those slots would have pointed to an inner table of entries, i.e. it stands in for page-entries that the flat table reserves but the tree never allocates. The tree marks those unused top entries invalid, allocating no inner table for them (see Page Faults and Demand Paging for what "invalid" triggers on access). Answer: flat ; two-level .
L4 — Synthesis
Problem 4.1
A 64-bit machine uses and a four-level page table with a 48-bit usable virtual address (like x86-64), each level a 9-bit index. Verify the field widths add up, and compute how many RAM accesses a full walk needs, then the total to actually read the target byte.
Recall Solution 4.1
WHAT: check , then count accesses. Offset bits: . Four index levels of 9 bits each: WHY 9-bit levels: — each table is one page (64-bit PTEs are 8 bytes). Same "table = one page" trick as L3. Walk cost: each level is one memory read to fetch the next-level pointer, so a 4-level walk = 4 reads. Then one more read for the actual data byte: Answer: widths sum to 48; walk = 4 reads; total to reach data = 5 reads.
Problem 4.2
Using the model , suppose cycle, walk cost memory reads 100 cycles/read cycles, and the TLB miss rate is . Compute the average translation time. Then find the miss rate that would double it.
Recall Solution 4.2
Term note: here "walk cost" means only the page-table reads that find the frame — the 4 translation accesses of Problem 4.1, not the final data fetch. The data read is a separate cost that happens after translation regardless, so it does not belong in a translation-time model. (If you ever include it, say "translation + data" = 5 reads, as in Problem 4.1.) WHAT: plug in, then invert for the target. Doubling means target cycles. Solve for the miss rate : WHY this matters: the walk cost dominates whenever the miss rate is non-tiny, which is why the TLB exists — see Cache Memory Basics for the same "hit fast / miss slow" trade-off. Answer: avg cycles; doubling needs miss rate ().
L5 — Mastery
Problem 5.1
You are designing paging for a new 32-bit CPU. You may pick page size and 1, 2, or 3 levels. Requirement: every table must fit in exactly one page, PTEs are 4 bytes. For , how many entries fit in one page-table page, how many index bits is that, and does a clean 2-level design cover all bits? Show the split.
Recall Solution 5.1
WHAT: derive the per-page index width, then fit the levels to . bytes ⇒ offset bits, VPN bits. Entries per one-page table: entries, i.e. a 12-bit index per level. Can 2 levels cover 18 VPN bits? Two 12-bit indices give bits of indexing capacity — more than the we need, so yes, comfortably. A clean split uses one full 12-bit level and a smaller top level: WHY the top level is only 6 bits: the top table then uses just of its 4096 possible slots — it doesn't have to be full; unused high slots are simply marked invalid. This is legal because indexing capacity () VPN width (). Answer: ⇒ 4096 entries/page = 12-bit index; 2 levels (12+12=24 ≥ 18) suffice; split .
Problem 5.2
Defend or refute: "For this same 32-bit, machine, a single-level flat table is now perfectly reasonable — no tree needed." Back it with a size calculation and one design caveat.
Recall Solution 5.2
WHAT: size the flat table, then judge. Flat table entries . With 4-byte PTEs: Verdict — partly defensible: 1 MiB is far smaller than the 4 KiB-page case's 4 MiB, because bigger pages mean fewer pages to track ( dropped from 20 to 18, and each page covers 4× more memory). For a machine with few processes, 1 MiB flat can be acceptable. Caveat (why we still prefer a tree): the flat 1 MiB is allocated whole even for a process touching two pages; a tree would need only top table used inner tables. And 16 KiB pages waste memory via internal fragmentation (a 1-byte allocation still burns a 16 KiB frame). Trade-off is space-vs-space here, not the usual space-vs-time. Answer: flat table ; defensible for low process counts but the tree still wins on sparse usage; 16 KiB pages raise internal fragmentation.
Recall One-line summaries to self-quiz
Offset bits from page size ::: . Flat 32-bit / 4 KiB table size ::: . Two-level, 1 code + 1 stack page ::: (top + 2 inner tables). x86-64 4-level walk memory reads (miss) ::: 4 to translate, 5 including the data read. What a tree buys vs what a TLB buys ::: tree buys space, TLB buys time.
Parent: Page tables and multi-level paging · See also Address Space Layout, Virtual Memory, TLB and Translation Caching.