Skip to content
Official PYQ · 2021

GATE CS 2021 Set 2 Q48 — Memory Management and Virtual Memory

Explain with AI

Consider a three-level page table to translate a 39−39-bit virtual address to a physical address as shown below:

The page size is 4 KB  (1KB=210\text{4 KB} \;(1\text{KB}=2^{10} bytes)) and page table entry size at every level is 88 bytes. A process PP is currently using 2GB  (1GB=2302\text{GB}\;(1 \text{GB}=2^{30} bytes)) virtual memory which is mapped to 2GB2\text{GB} of physical memory. The minimum amount of memory required for the page table of PP across all levels is _________ KB\text{KB}.

View worked solution

Answer: 4108 : 4108

To find the minimum memory required, we break down the virtual address and assume the process's virtual memory is allocated contiguously to minimize the number of higher-level page tables.

1. Address Translation Breakdown:

  • Page Size = 4 KB=212 bytes  ⟹  Offset=12 bits4 \text{ KB} = 2^{12} \text{ bytes} \implies \text{Offset} = 12 \text{ bits}
  • Page Table Entry (PTE) size = 8 bytes8 \text{ bytes}
  • Number of entries per page table page = 4 KB8 B=512=29  ⟹  9 bits\frac{4 \text{ KB}}{8 \text{ B}} = 512 = 2^9 \implies 9 \text{ bits} per level
  • This matches the 3-level page table structure: 9 bits (L1)+9 bits (L2)+9 bits (L3)+12 bits (Offset)=39 bits9 \text{ bits (L1)} + 9 \text{ bits (L2)} + 9 \text{ bits (L3)} + 12 \text{ bits (Offset)} = 39 \text{ bits}

2. Number of Pages to Map:

Total Pages=2 GB4 KB=231 B212 B=219 pages\text{Total Pages} = \frac{2 \text{ GB}}{4 \text{ KB}} = \frac{2^{31} \text{ B}}{2^{12} \text{ B}} = 2^{19} \text{ pages}

3. Minimum Page Tables Required (Contiguous Allocation):

  • Level 3: Each L3 page table maps 29=5122^9 = 512 pages. L3 tables=21929=210=1024\text{L3 tables} = \frac{2^{19}}{2^9} = 2^{10} = 1024
  • Level 2: Each L2 page table maps 29=5122^9 = 512 L3 tables. L2 tables=⌈1024512⌉=2\text{L2 tables} = \left\lceil \frac{1024}{512} \right\rceil = 2
  • Level 1: Always 11 root page table.

4. Total Memory Calculation:

Total Page Tables=1 (L1)+2 (L2)+1024 (L3)=1027 tables\text{Total Page Tables} = 1 \text{ (L1)} + 2 \text{ (L2)} + 1024 \text{ (L3)} = 1027 \text{ tables}

Total Memory=1027×4 KB=4108 KB\text{Total Memory} = 1027 \times 4 \text{ KB} = 4108 \text{ KB}

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

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