Question
Consider a 32-bit system with 4 KB page size and page table entries of size 4 bytes each. Assume 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 denote the minimum and denote the maximum number of pages across the two levels of the page table of the process.
The value of is ________
Official answer and solution
- Official answer
- 1028
- From
- Official GATE 2024 answer key
Solution
Determine the number of PTEs per page (), then find the minimum () and maximum () number of inner page table pages needed for 2000 valid PTEs, plus 1 outer page directory page each.
- Page table geometry:
- Page size bytes; PTE size bytes.
- Number of entries per page table page entries.
- In the 32-bit virtual address ( split), the outer page directory occupies 1 page and points to up to 1024 inner page table pages, each holding up to 1024 PTEs.
- Minimum page table pages ():
- To minimize the number of inner page table pages for unique virtual pages, pack the valid PTEs contiguously into inner page table pages.
- Including the outer page directory page: .
- Maximum page table pages ():
- To maximize the number of inner page table pages, spread the valid PTEs across as many inner page table pages as possible. Since there are only possible inner page table pages in total and , all inner page table pages can contain at least one valid PTE.
- Including the outer page directory page: .
- Sum:
1028
Assuming the maximum number of inner page table pages is 2000 (one per accessed page) without noticing that the outer page directory has only 1024 entries.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2024 Computer Science and Information Technology - Set 2 (CS2)
- Question
- 64 of 65
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.