GATE / CS ARCHIVE

SIMILAR QUESTIONS / OPERATING SYSTEMS

Count allocated multilevel page table pages

3 questions solved the same way, newest first. Back to Operating Systems

How these are solved

Map used virtual pages to leaf-table regions and distinct ancestors, counting shared root/parents once. 2003 gives sparse explicit addresses;

2 marks · NAT
Report issue

Minimize and maximize two-level page-table storage

Virtual Memory & Paging

Question 64, GATE 2024: A 32-bit byte-addressed system uses 4 KiB pages and 4-byte PTEs. Each process receives one outer directory page. Inner table pages are allocated only when they hold a valid mapping. A process accesses 2000 distinct pages and none is swapped out. Let X and Y be minimum and maximum total page-table pages over both levels. Find X+Y; do not count data pages.
Tap to enlarge
Answer & solution

Official answer: 1028

Approach: Compute how many data-page mappings each inner table can hold and how many inner tables the directory can address.

1. Derivation. A4KB table page holds 4096/4=1024 entries. The32-bit address divides into 10 outer-index bits, 10 inner-index bits and 12 offset bits, allowing 1024 inner table pages. Minimum table storage for 2000 mapped pages packs them into ceil(2000/1024)=2 inner pages plus the allocated outer page: X=3. Maximum spreads mappings across all 1024 distinct outer entries, possible with 2000 pages, giving Y=1024+1=1025. Thus X+Y=1028. Data pages themselves are not counted.

2. Explanation and checks. To achieve the minimum, map 1024 data pages through one outer entry and the remaining 976 through a second. To achieve the maximum, use at least one data page in each of the 1024 outer regions; the remaining 976 accesses can fall in regions already used. This construction shows the upper bound is attainable, not just theoretical. An outer entry does not itself map one data page: it selects an entire inner table, so counting 2000 table pages would be incorrect.

Original paper, page 40 · Answer key

2 marks · NAT
Report issue

Virtual Memory & Paging

Question 48, GATE 2021: 39-bit virtual address splits as 9-bit level1,9-bit level2,9-bit level3,12-bit offset. Pages are 4KB and all PTEs 8 bytes. Process maps 2GB virtual to 2GB physical. Find minimum total page-table memory in KB, with binary KB/GB.
Tap to enlarge
Answer & solution

Official answer: 4108

Each page-table page holds 4096/8=512 entries. The2GB mapping needs 231/212=219 leaf entries, hence 1024 level3 pages. Packing these contiguously minimizes higher levels: 1024/512=2 level2 pages and one level1 root page. Total=(1024+2+1)*4KB=4108KB. This is the minimum with allocated whole page-table pages and a densely placed virtual mapping.

Each level-2 page indexes up to 512 level-3 pages, which collectively map 512×512×4KB=1GB. Thus the 2GB region can occupy two such subtrees under one root. Sparse placement could require more page-table pages; the word minimum permits contiguous, suitably aligned placement. Physical page contents consume 2GB but are not part of page-table overhead.

Original paper, page 85 · Answer key

2 marks · MCQ
Report issue

Memory used by sparse two-level page tables

Virtual Memory & Paging

Question 79, GATE 2003: A byte-addressable processor has 32-bit virtual and physical addresses and two-level page tables stored in main memory. Address bits are split 10 bits for first-level index, 10 for second-level index, and 12 for page offset. All page-table entries are 4 bytes. TLB hit rate is 96%, physical-cache hit rate 90%; TLB and cache access each take 1 ns, and main memory takes 10 ns. A process maps only two contiguous code pages starting at 0x00000000, two contiguous data pages starting at 0x00400000, and one stack page starting at 0xFFFFF000. How much storage is needed for its page tables?
A. 8 KB  B. 12 KB  C. 16 KB  D. 20 KB
Question 79, GATE 2003: A byte-addressable processor has 32-bit virtual and physical addresses and two-level page tables stored in main memory. Address bits are split 10 bits for first-level index, 10 for second-level index, and 12 for page offset. All page-table entries are 4 bytes. TLB hit rate is 96%, physical-cache hit rate 90%; TLB and cache access each take 1 ns, and main memory takes 10 ns. A process maps only two contiguous code pages starting at 0x00000000, two contiguous data pages starting at 0x00400000, and one stack page starting at 0xFFFFF000. How much storage is needed for its page tables?
A. 8 KB  B. 12 KB  C. 16 KB  D. 20 KB
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. A 10-bit index selects 1024 entries. At four bytes per entry each full table occupies 4096 bytes, one 4 KiB page.
2. One second-level table covers 1024 virtual pages, or 1024×4096=4 MiB. The code pages fall in the first 4 MiB region, top-level index 0. The data begins exactly at 4 MiB, index 1. The stack address has index 1023.
3. The two contiguous code pages share one second-level table, as do the two data pages. The stack needs a third second-level table. Add one top-level table: four tables total.
4. Storage=4×4096=16384 bytes=16 KiB, option C. Mapped content pages are not additional page-table storage.

Solution: Each page-table level has 210 entries of four bytes, so each allocated table uses 4096 bytes. The two code pages occupy top-level index 0; the two data pages starting at 0x00400000 occupy index 1; the stack page at 0xFFFFF000 occupies index 1023. Three second-level tables are therefore required, plus the first-level table. Total page-table storage is 4×4096=16384 bytes=16 KiB, option C. The five mapped code/data/stack pages are not themselves included in page-table storage.

Original paper, page 12