Skip to content
Official PYQ · 2024

GATE CS 2024 Set 2 Q54 — Memory Management and Virtual Memory

Explain with AI
Consider a 3232-bit system with 4 KB4 \mathrm{~KB} page size and page table entries of size 44 bytes each. Assume 1 KB=2101 \mathrm{~KB}=2^{10} bytes. The OS uses a 22-level page table for memory management, with the page table containing an outer page directory and an inner page table. The OS\text{OS} allocates a page for the outer page directory upon process creation. The OS\text{OS} uses demand paging when allocating memory for the inner page table, i.e., a page of the inner page table is allocated only if it contains at least one valid page table entry.

An active process in this system accesses 20002000 unique pages during its execution, and none of the pages are swapped out to disk. After it completes the page accesses, let X\text{X} denote the minimum and Y\text{Y} denote the maximum number of pages across the two levels of the page table of the process.

The value of X+Y\text{X+Y} is ___________.
View worked solution

Answer: 1028

To solve this problem, we first analyze the structure of the 2-level page table:

  • Page Size: 4 KB=212 bytes4\text{ KB} = 2^{12}\text{ bytes} (Offset = 1212 bits).
  • Page Table Entry (PTE) size: 4 bytes4\text{ bytes}.
  • Entries per page: 4 KB4 bytes=1024=210\frac{4\text{ KB}}{4\text{ bytes}} = 1024 = 2^{10} entries.

Since the system uses a 2-level page table for a 32-bit address space, the virtual address is split as follows:

VA=10 bits (Outer Index)+10 bits (Inner Index)+12 bits (Offset)\text{VA} = 10\text{ bits (Outer Index)} + 10\text{ bits (Inner Index)} + 12\text{ bits (Offset)}

Thus, the outer page directory contains 10241024 entries, pointing to a maximum of 10241024 inner page tables. Each inner page table covers 10241024 pages of virtual memory.

The process accesses 20002000 unique pages. The outer page directory is always allocated (11 page).

1. Minimum Pages (XX):
To minimize the number of inner page tables, the 20002000 pages should be clustered as contiguously as possible. Since each inner page table covers 10241024 pages, the minimum number of inner page tables required is: ⌈20001024⌉=2 inner page tables\left\lceil \frac{2000}{1024} \right\rceil = 2 \text{ inner page tables} X=1 (outer)+2 (inner)=3 pagesX = 1 \text{ (outer)} + 2 \text{ (inner)} = 3 \text{ pages}

2. Maximum Pages (YY):
To maximize the number of inner page tables, the 20002000 pages should be distributed across as many different inner page tables as possible. Since there are at most 10241024 inner page tables and 2000≥10242000 \ge 1024, we can distribute the pages such that every one of the 10241024 inner page tables contains at least one active page. Y=1 (outer)+1024 (inner)=1025 pagesY = 1 \text{ (outer)} + 1024 \text{ (inner)} = 1025 \text{ pages}

Calculating X+YX + Y:
X+Y=3+1025=1028X + Y = 3 + 1025 = 1028

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Memory Management and Virtual Memory questions