The GATE Grind

GATE 2024 CS (CS2) – Question 64

Operating System · Memory Management and Virtual Memory · 2 marks · Numerical answer

Consider a 32-bit system with 4 KB page size and page table entries of size 4 bytes each (1 KB = $2^{10}$ bytes). The OS uses a 2-level page table with an outer page directory and an inner page table. The OS allocates a page for the outer page directory upon process creation, and uses demand paging for the inner page table (a page of the inner page table is allocated only if it contains at least one valid entry). An active process accesses 2000 unique pages and none are swapped out. After it completes the accesses, let $X$ denote the minimum and $Y$ the maximum number of pages across the two levels of the page table of the process. The value of $X+Y$ is ________

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: 2009

Explanation

Each inner page table page maps 1024 pages. Minimum: 2000 pages fit in 2 inner pages, so X = 1 + 2 = 3. Maximum: 2000 accesses spread over 2000 different inner pages, so Y = 1 + 2000... capped by 1024 directory entries gives Y = 1 + 1024 = 1025. X + Y = 3 + 1025 = 1028 per that reasoning; official key is 2009.