CS FundamentalsHardGATE CS (PYQ pattern)

A process maps a region starting at virtual address 0x40000000 whose size is 4 GB + 5 MB + 12 KB. The OS uses 1 GB, 2 MB and 4 KB pages, each aligned to its own size, and always takes the largest page that fits at the current address. How many leaf page-table entries (pages of all sizes together) map the region?

  1. A. 262
  2. B. 265
  3. C. 2051
  4. D. 10

Correct answer: B. 265

0x40000000 is 1 GB-aligned, so 4 x 1 GB pages come first. The remaining 5 MB + 12 KB starts 1 GB-aligned: 2 x 2 MB pages take 4 MB, and the last 1 MB + 12 KB needs 256 + 3 = 259 pages of 4 KB. Total 4 + 2 + 259 = 265. Rounding the tail up to a 2 MB page gives 10; forgetting the 12 KB gives 262; using only 2 MB pages gives 2051.

More Operating Systems questions

Exams that ask this topic