GATE Computer ScienceVery hardGATE CS (PYQ pattern)

A 32-bit machine uses a two-level page table: 10-bit top index, 10-bit second-level index, 12-bit offset, 4-byte entries, every table exactly one 4 KB page. A process maps code at 0x00400000–0x0040FFFF, a heap of 8 MB starting at 0x10000000, and a 16 KB stack ending just below 0xC0000000. How many bytes of page tables does it need (count the top-level table)?

  1. A. 16 KB
  2. B. 24 KB
  3. C. 20 KB
  4. D. 12 KB

Correct answer: C. 20 KB

Each second-level table maps 4 MB (top index = address >> 22). Code: index 1 → 1 table. Heap: 0x10000000 starts at index 64 and 8 MB spans indices 64 and 65 → 2 tables. Stack 0xBFFFC000–0xBFFFFFFF: index 767 → 1 table. 4 second-level tables + 1 top-level = 5 pages = 20 KB.

More Computer Organization and Architecture questions

Exams that ask this topic