GATE / CS ARCHIVE

SIMILAR QUESTIONS / OPERATING SYSTEMS

Derive hierarchical page table index widths

3 questions solved the same way, newest first. Back to Operating Systems

How these are solved

Subtract data-page offset and derive table fanout from page bytes/PTE bytes. Apply the stated hierarchy to infer equal index/offset split, required depth, or outer-index width.

2 marks · NAT
Report issue

Virtual Memory & Paging

Question 58, GATE 2025: A byte-addressable logical space has 2^32 bytes and uses two-level paging with 4096-byte pages. Each inner-page-table entry takes 8 bytes, and an inner table occupies one page. An address contains b outer-index bits, an inner-table entry index, and a data-page offset. Find b.
Tap to enlarge
Answer & solution

Official answer: 11

A 4096-byte data page needs log2(4096)=12 offset bits. An inner page table stored in one 4096-byte page holds 4096/8=512=29 entries. Selecting one of those entries therefore needs 9 bits.

The complete logical address has 32 bits, so the remaining outer index has b=32−12−9=11 bits. As a coverage check, each inner table maps 512 data pages, or 512·4096=221 bytes. A 232-byte space therefore needs 232−21=211 such inner-table slots in its outer table.

Do not allocate 12 independent address bits to the inner entry index just because an inner-table page is 4096 bytes. Entries are 8 bytes each; their byte offsets are aligned, leaving only 9 independent selection bits. The question does not require the entire outer table to fit a single page. Answer: 11.

Original paper, page 44 · Answer key

2 marks · NAT
Report issue

Virtual Memory & Paging

Question 58, GATE 2023: A 57-bit virtual address uses an L-level tree of page tables. Pages are 4 KiB; each page-table entry is 8 bytes at every level. Find L under the conventional one-page-per-table-node layout.
Tap to enlarge
Answer & solution

Official answer: 5

Step through it (8 steps)

A 4 KiB page has a 12-bit offset. Under the conventional one-page-per-page-table-node layout, each node holds 4096/8=512 entries and contributes 9 index bits. The virtual page number has 57-12=45 bits, requiring L=45/9=5 levels. The page-sized table-node convention is implicit in this standard multilevel-paging calculation.

Teaching detail. The address must be partitioned into a page offset and a sequence of table indexes. Offset bits select one byte within 4096 bytes, so there are 12. Each page-sized table contains 512 entries, whose selection requires 9 bits. Five indexes account for 45 virtual-page bits and, together with the 12-bit offset, exactly cover 57 bits. In cases where this division is not exact, the top-level index can be shorter; here no partial level is needed. The result depends on page-sized table nodes, not merely on entry width alone.

Original paper, page 61 · Answer key

Descriptive
Report issue

Two-level address translation with equal index widths

Virtual Memory & Paging

Question 19(a), GATE 2002: Virtual and physical addresses are 32 bits, byte addressed, page size 4 KB, two-level page tables with equal index widths, each entry 4 bytes. Original19(a): Draw how a virtual address translates to a physical address.
Question 19(a), GATE 2002: Virtual and physical addresses are 32 bits, byte addressed, page size 4 KB, two-level page tables with equal index widths, each entry 4 bytes. Original19(a): Draw how a virtual address translates to a physical address.
Tap to enlarge
Answer & solution

Answer: Virtual address: 10-bit outer index | 10-bit inner index | 12-bit offset; physical address: 20-bit frame number | 12-bit offset. (no official key was published)

A 4 KiB page has 212 bytes, so the low 12 address bits are the unchanged page offset. The remaining 32−12=20 virtual-page bits split equally into two 10-bit indices. The translation is:
VA[31:22] --index--> first-level table --second-level table base
VA[21:12] --index into that table--> second-level entry --20-bit physical frame number
PA = (physical frame number << 12) | VA[11:0].
More explicitly, the first entry is at first_table_base + 4·VA[31:22]; it identifies the second-level table. The second entry is at second_table_base + 4·VA[21:12]; it identifies the data page frame. Validity and protection flags are checked along the way; absent or disallowed mappings fault. The diagram describes a successful translation and does not require a TLB assumption.

Original paper, page 10