CS FundamentalsVery hardProduct company interview · GATE level

A machine has 40-bit virtual addresses, 16 KB pages and 4-byte page-table entries. Every page table at every level must fit in a single page. How many levels of page tables are needed, and how many entries of the outermost table can ever be used?

  1. A. 3 levels; 4 entries
  2. B. 2 levels; 4096 entries
  3. C. 3 levels; 4096 entries
  4. D. 4 levels; 64 entries

Correct answer: A. 3 levels; 4 entries

The offset takes log2(16 K) = 14 bits, leaving 26 bits of page number. One page holds 16 KB / 4 B = 4096 entries, so each level resolves 12 bits. 26 bits need ceil(26/12) = 3 levels: 12 + 12 for the inner levels and only 2 bits for the outermost, so just 2^2 = 4 of its 4096 entries are usable. Two levels would resolve only 24 bits; a single table would need 2^26 entries, i.e. 256 MB.

More Operating Systems questions

Exams that ask this topic