GateAI
Memory Management and Virtual Memory

GATE CSE 2024 Set 2 · Q64

NAT2 marksMedium

Time

Consider a 32-bit system with 4 KB page size and page table entries of size 4 bytes each. Assume 1 KB = 2102^{10} bytes. The OS uses a 2-level page table for memory management, with the page table containing an outer page directory and an inner page table. The OS allocates a page for the outer page directory upon process creation. The 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 2000 unique pages during its execution, and none of the pages are swapped out to disk. After it completes the page accesses, let XX denote the minimum and YY denote the maximum number of pages across the two levels of the page table of the process. The value of X+YX+Y is _______

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 1028

Memory Management and Virtual Memory

### Step 1: Determine the page table structure

  • Virtual Address Size:32 bits32\text{ bits}

  • Page Size: 4 KB=212 bytes  ⟹  12 bits for page offset4\text{ KB} = 2^{12}\text{ bytes} \implies 12\text{ bits for page offset}.

  • Page Table Entry (PTE) Size: 4 bytes=22 bytes4\text{ bytes} = 2^2\text{ bytes}.

  • Number of entries per inner page table page:

    Page SizePTE Size=4 KB4 B=21222=210=1024 entries\frac{\text{Page Size}}{\text{PTE Size}} = \frac{4\text{ KB}}{4\text{ B}} = \frac{2^{12}}{2^2} = 2^{10} = 1024\text{ entries}
  • Therefore, the inner page table requires 10 bits10\text{ bits}, leaving 32−12−10=10 bits32 - 12 - 10 = 10\text{ bits} for the outer page directory.

  • The outer page directory contains 210=10242^{10} = 1024 entries and occupies exactly 1 page1\text{ page}.

### Step 2: Compute the minimum number of pages (XX)

  • The outer page directory is always allocated: 1 page1\text{ page}.

  • The process accesses 20002000 unique pages.

  • To minimize the number of inner page table pages, these 20002000 entries should be packed into as few inner page table pages as possible.

  • Since each inner page table page can store up to 10241024 entries:

    Minimum inner page table pages=⌈20001024⌉=2 pages\text{Minimum inner page table pages} = \left\lceil \frac{2000}{1024} \right\rceil = 2\text{ pages}
  • Total minimum pages across both levels:

    X=1 (outer)+2 (inner)=3X = 1\text{ (outer)} + 2\text{ (inner)} = 3

### Step 3: Compute the maximum number of pages (YY)

  • To maximize the number of inner page table pages, the 20002000 accessed pages should be distributed across as many distinct outer page directory entries as possible.

  • The outer page directory has at most 10241024 entries, meaning there can be at most 10241024 inner page table pages.

  • Since 2000≥10242000 \ge 1024, all 10241024 inner page table pages can be allocated (each having at least 11 entry).

  • Total maximum pages across both levels:

    Y=1 (outer)+1024 (inner)=1025Y = 1\text{ (outer)} + 1024\text{ (inner)} = 1025

### Step 4: Calculate X+YX + Y

X+Y=3+1025=1028X + Y = 3 + 1025 = 1028

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Memory Management and Virtual Memory previous year question is Q64 of the GATE CSE 2024 Set 2 paper. Find more GATE CSE PYQs on Memory Management and Virtual Memory in Operating Systems, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Memory Management and Virtual Memory PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Memory Management and Virtual Memory in GATE CSE

Memory Management and Virtual Memory has 32 GATE CSE PYQs across 22 papers from 2011 to 2026. 15 of them are 2-mark NAT questions like this one, and GATE CSE 2024 Set 2 has 2.

How GATE tests Memory Management and Virtual Memory

More from GATE CSE 2024 Set 2

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2024 Set 2 · Q64 · NAT

Consider a 32-bit system with 4 KB page size and page table entries of size 4 bytes each. Assume 1 KB = 210 bytes. The OS uses a 2-level page table for memory management, with the page table containing an outer page directory and an inner page table. The OS allocates a page for the outer page directory upon process creation. The 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 2000 unique pages during its execution, and none of the pages are swapped out to disk. After it completes the page accesses, let X denote the minimum and Y denote the maximum number of pages across the two levels of the page table of the process. The value of X+Y is …

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.