chapter

    Memory Management, Paging and Virtual Memory Pyqs for Gate Cs

    Solve 14+ Memory Management, Paging and Virtual Memory previous year questions for GATE CS with answers and detailed solutions. Free sample questions below.

    Try a question

    Answer it here to see how it works. Nothing is recorded until you sign in.

    Question 1
    2026 Slot Set2 PYQ
    Level 3: Exam Standard
    A system has a Translation Lookaside Buffer (TLB) that has a reach of 1 MB. TLB reach is defined as the total amount of physical memory that can be accessed through the TLB entries. The paging system uses pages of size 4 KB. The virtual address space is 64 GB and physical address space is 1 GB. If each TLB entry stores a 4-bit process id, page number, frame number, and a 2-bit control field, then the size of the TLB (in bytes) is ___________. (answer in integer)

    Note: , ,
    Question 2
    2026 Slot Set2 PYQ
    Level 3: Exam Standard
    Consider contiguous allocation of physical memory to processes using variable partitioning scheme. Suppose there are 8 holes in the memory of sizes 20 KB, 4 KB, 25 KB, 18 KB, 7 KB, 9 KB, 15 KB, and 12 KB. Assume that no two holes are adjacent. Two processes P1 of size 16 KB and P2 of size 9 KB arrive in that order, and they are allocated memory using the best-fit technique. After allocating space to P1 and P2, the number of holes of size less than 8 KB is ____________. (answer in integer)

    Note:
    Question 3
    2025 Slot Set2 PYQ
    Level 3: Exam Standard
    A computer system supports a logical address space of bytes. It uses two-level hierarchical paging with a page size of 4096 bytes. A logical address is divided into a -bit index to the outer page table, an offset within the page of the inner page table, and an offset within the desired page. Each entry of the inner page table uses eight bytes. All the pages in the system have the same size.

    The value of is ___________ . (Answer in integer)
    Question 4
    2025 Slot Set2 PYQ
    Level 3: Exam Standard
    Consider a demand paging system with three frames, and the following page reference string: 1 2 3 4 5 4 1 6 4 5 1 3 2. The contents of the frames are as follows initially and after each reference (from left to right):

    initiallyafter-1*2*3*4*5*416*451*3*2*-1111111666662--224444444111---33555555533
    The *-marked references cause page replacements.

    Which one or more of the following could be the page replacement policy/policies in use?
    Question 5
    2025 Slot Set1 PYQ
    Level 3: Exam Standard

    Consider a demand paging memory management system with 32-bit logical address, 20-bit physical address, and page size of 2048 bytes. Assuming that the memory is byte addressable, what is the maximum number of entries in the page table?

    Question 6
    2025 Slot Set1 PYQ
    Level 3: Exam Standard
    In optimal page replacement algorithm, information about all future page references is available to the operating system (OS). A modification of the optimal page replacement algorithm is as follows:

    The OS correctly predicts only up to next 4 page references (including the current page) at the time of allocating a frame to a page.

    A process accesses the pages in the following order of page numbers:


    If the system has three memory frames that are initially empty, the number of page faults that will occur during execution of the process is ________. (Answer in integer)
    Question 7
    2024 Slot Set2 PYQ
    Level 3: Exam Standard
    Consider a 32-bit system with 4 KB page size and page table entries of size 4 bytes each. Assume 1 KB = 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 __________
    Question 8
    2024 Slot Set2 PYQ
    Level 3: Exam Standard

    Which of the following tasks is/are the responsibility/responsibilities of the memory management unit (MMU) in a system with paging-based memory management?

    Question 9
    2024 Slot Set1 PYQ
    Level 3: Exam Standard

    Consider a memory management system that uses a page size of 2 KB. Assume that both the physical and virtual addresses start from 0. Assume that the pages 0, 1, 2, and 3 are stored in the page frames 1, 3, 2, and 0, respectively. The physical address <i>(in decimal format)</i> corresponding to the virtual address 2500 <i>(in decimal format)</i> is _________

    Question 10
    2023 PYQ
    Level 3: Exam Standard
    Consider the following two-dimensional array D in the C programming language, which is stored in row-major order:

    int D[128][128];

    Demand paging is used for allocating memory and each physical page frame holds 512 elements of the array D. The Least Recently Used (LRU) page-replacement policy is used by the operating system. A total of 30 physical page frames are allocated to a process which executes the following code snippet:

    for (int i = 0; i < 128; i++)
       for (int j = 0; j < 128; j++)
          D[j][i] *= 10;

    The number of page faults generated during the execution of this code snippet is __________.
    Free preview ends here

    Login to view the complete previous-year questions and solutions

    Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.

    Explore complete test series, official past papers, and chapter-wise study tools.

    Why MastersUp

    Personalised first. High quality throughout.

    Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.

    Built around you, not around a syllabus PDF

    Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.

    Revision that hits your weak spots

    We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.

    Questions calibrated to the real exam

    Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.

    Notes written for recall, not for volume

    Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.

    One place for everything

    Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.

    Honest progress

    No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.

    Unlock the whole course

    Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.

    Memory Management, Paging and Virtual Memory PYQs for GATE CS

    Solve 14+ Memory Management, Paging and Virtual Memory previous year questions for GATE CS with answers and detailed solutions. Free sample questions below.

    Topic Boundary and Anchor Scenario

    Topic Boundary & Anchor Scenario

    This topic covers paging mechanics, page table structures, address translation arithmetic, Translation Lookaside Buffer (TLB) operation, and Effective Access Time (EAT). It explicitly excludes page replacement algorithms, page fault handling procedures, and contiguous memory allocation, which are owned by sibling topics. We will use a consistent anchor scenario: a system with a 32-bit virtual address, 20-bit physical address, 4 KB page size, 4-byte Page Table Entries (PTEs), and a 64-entry 2-way set-associative TLB.

    Explain this more simply

    Think of this anchor scenario as a controlled laboratory setup. Every calculation we perform will use these exact numbers. This prevents cognitive overload from constant unit conversions and allows you to isolate the specific mechanism being tested in each card.

    Go one level deeper

    The anchor scenario is deliberately chosen because a 32-bit virtual address with 4 KB pages yields exactly entries. This cleanly maps to a 4 MB single-level page table, exposing the precise mathematical threshold where multi-level structures become mandatory, without introducing messy fractional page allocations.

    Virtual versus Physical Address Space

    Virtual vs Physical Address Space

    Virtual Address: Index into logical memory space.
    Physical Address: Index into actual hardware RAM.

    Anchor: 32-bit VA (4 GB) vs 20-bit PA (1 MB)

    A virtual address is an index into a process's logical memory space, while a physical address is an index into the actual hardware RAM. In our anchor scenario, the 32-bit virtual address allows a process to request up to 4 GB of memory ( bytes). However, the 20-bit physical address means the machine only has 1 MB of actual RAM installed ( bytes).

    Explain this more simply

    Imagine a library catalog versus the actual bookshelves. The catalog can list millions of books, even if the building only has physical space for a few hundred. The operating system maps the catalog entries to the available shelves dynamically.

    Go one level deeper

    The hardware does not care if the virtual address space exceeds the physical address space. The Memory Management Unit (MMU) blindly performs the translation. If the target physical frame is absent or invalid, the MMU raises a trap, delegating the resolution to the operating system's page fault handler.

    Memory Management, Paging and Virtual Memory: Solved Questions with Step-by-Step Explanations (10 Problems)

    Question 1 · Operating System · 2026_Set2 NAT
    A system has a Translation Lookaside Buffer (TLB) that has a reach of 1 MB. TLB reach is defined as the total amount of physical memory that can be accessed through the TLB entries. The paging system uses pages of size 4 KB. The virtual address space is 64 GB and physical address space is 1 GB. If each TLB entry stores a 4-bit process id, page number, frame number, and a 2-bit control field, then the size of the TLB (in bytes) is ___________. (answer in integer)

    Note: , ,
    Correct Answer:

    1536.00

    Step-by-Step Solution

    Insight: TLB size is the number of entries multiplied by the size of each entry. The number of entries is derived directly from the TLB reach and the page size.

    Exam route:

    1. TLB entries = TLB reach / page size = 1 MB / 4 KB = 2^20 / 2^12 = 256.
    2. Virtual address = 64 GB = 2^36 bytes. VPN bits = 36 - 12 = 24.
    3. Physical address = 1 GB = 2^30 bytes. PFN bits = 30 - 12 = 18.
    4. Entry size = 4 (PID) + 24 (VPN) + 18 (PFN) + 2 (control) = 48 bits = 6 bytes.
    5. Total TLB size = 256 * 6 = 1536 bytes.

    Learning route:

    This is a TLB architecture and sizing question.

    Step 1: Calculate the number of entries in the TLB. The TLB reach is the total physical memory that can be accessed through the TLB. Reach = Number of entries Page size. Therefore, Number of entries = 1 MB / 4 KB = entries.

    Step 2: Determine the Virtual Page Number (VPN) bits. The virtual address space is 64 GB = bytes. The page size is 4 KB = bytes. VPN bits = bits.

    Step 3: Determine the Physical Frame Number (PFN) bits. The physical address space is 1 GB = bytes. PFN bits = bits.

    Step 4: Calculate the size of a single TLB entry. The entry stores: 4-bit process ID + 24-bit VPN + 18-bit PFN + 2-bit control field = 48 bits.

    Step 5: Convert bits to bytes. 48 bits / 8 = 6 bytes per entry.

    Step 6: Calculate the total TLB size. Total size = Number of entries Size per entry = bytes.

    Question 2 · Operating System · 2026_Set2 NAT
    Consider contiguous allocation of physical memory to processes using variable partitioning scheme. Suppose there are 8 holes in the memory of sizes 20 KB, 4 KB, 25 KB, 18 KB, 7 KB, 9 KB, 15 KB, and 12 KB. Assume that no two holes are adjacent. Two processes P1 of size 16 KB and P2 of size 9 KB arrive in that order, and they are allocated memory using the best-fit technique. After allocating space to P1 and P2, the number of holes of size less than 8 KB is ____________. (answer in integer)

    Note:
    Correct Answer:

    3.00

    Step-by-Step Solution

    Insight: Best-fit allocates the smallest hole that is large enough, which can leave tiny, unusable fragments. We must track the hole sizes step-by-step.

    Exam route:

    1. Initial holes: 20, 4, 25, 18, 7, 9, 15, 12 KB.
    2. P1 (16 KB): Best fit is 18 KB. Remaining = 18 - 16 = 2 KB.
    3. Holes: 20, 4, 25, 2, 7, 9, 15, 12 KB.
    4. P2 (9 KB): Best fit is 9 KB. Remaining = 9 - 9 = 0 KB (hole disappears).
    5. Holes: 20, 4, 25, 2, 7, 15, 12 KB.
    6. Holes < 8 KB: 4, 2, 7. Count = 3.

    Learning route:

    This is a dynamic allocation simulation question. We apply the best-fit rule strictly in the order of process arrival.

    Step 1: List the initial holes: 20, 4, 25, 18, 7, 9, 15, 12.

    Step 2: Process P1 (16 KB) arrives. We search for holes 16 KB. The candidates are 20, 25, and 18. The best fit is the smallest of these, which is 18 KB.

    Step 3: Allocate 16 KB from the 18 KB hole. The remaining space is 18 - 16 = 2 KB. The updated hole list is: 20, 4, 25, 2, 7, 9, 15, 12.

    Step 4: Process P2 (9 KB) arrives. We search for holes 9 KB. The candidates are 20, 25, 9, 15, 12. The best fit is exactly 9 KB.

    Step 5: Allocate 9 KB from the 9 KB hole. The remaining space is 0 KB, meaning this hole is completely consumed and disappears from the list. The updated hole list is: 20, 4, 25, 2, 7, 15, 12.

    Step 6: Count the holes strictly less than 8 KB. The sizes are 4, 2, and 7. There are exactly 3 such holes.

    Question 3 · Operating System · 2025_Set2 NAT
    A computer system supports a logical address space of bytes. It uses two-level hierarchical paging with a page size of 4096 bytes. A logical address is divided into a -bit index to the outer page table, an offset within the page of the inner page table, and an offset within the desired page. Each entry of the inner page table uses eight bytes. All the pages in the system have the same size.

    The value of is ___________ . (Answer in integer)
    Correct Answer:

    11.00

    Step-by-Step Solution

    Insight: The sum of the bits for the outer index, inner index, and page offset must exactly equal the total logical address bits.

    Exam route:

    1. Page size = 4096 = 2^12 bytes -> offset = 12 bits.
    2. Inner page table fits in one page (4096 bytes). Entry size = 8 bytes.
    3. Inner index bits = log2(4096 / 8) = log2(512) = 9 bits.
    4. Total logical address = 32 bits.
    5. Outer index b = 32 - 12 - 9 = 11 bits.

    Learning route:

    This is a two-level page table index bit calculation question.

    Step 1: Identify the page offset bits. The page size is 4096 bytes, which is bytes. Therefore, the page offset requires 12 bits.

    Step 2: Determine the number of entries in a single inner page table. The problem states that all pages have the same size, so an inner page table occupies exactly one page (4096 bytes). Each entry uses 8 bytes.

    Step 3: Calculate the inner page table index bits. The number of entries per inner page table is . Since , the inner page table index requires 9 bits.

    Step 4: Calculate the outer page table index bits (). The total logical address space is bytes, meaning the logical address is 32 bits long. The address is divided into three parts: outer index (), inner index (9), and offset (12).

    Step 5: Solve for : .

    Question 4 · Operating System · 2025_Set2 MSQ
    Consider a demand paging system with three frames, and the following page reference string: 1 2 3 4 5 4 1 6 4 5 1 3 2. The contents of the frames are as follows initially and after each reference (from left to right):

    initiallyafter-1*2*3*4*5*416*451*3*2*-1111111666662--224444444111---33555555533
    The *-marked references cause page replacements.

    Which one or more of the following could be the page replacement policy/policies in use?
    1. A.

      Least Recently Used page replacement policy

    2. B.

      Least Frequently Used page replacement policy

    3. C.

      Most Frequently Used page replacement policy

    4. D.

      Optimal page replacement policy

    Correct Answer:

    ["D"]

    Step-by-Step Solution

    Insight: By tracing the frame contents step-by-step and comparing the evicted page against the rules of each algorithm, we can eliminate policies that violate the observed replacements.

    Exam route:

    1. Ref 4: Frames {1,2,3}. Future: 5,4,1,6,4,5,1,3,2. Next use: 1(pos 7), 2(pos 13), 3(pos 12). Furthest is 2. Optimal replaces 2. Matches table.
    2. Ref 5: Frames {1,4,3}. Future: 4,1,6,4,5,1,3,2. Next use: 1(pos 7), 4(pos 9), 3(pos 12). Furthest is 3. Optimal replaces 3. Matches table.
    3. Ref 6: Frames {1,4,5}. Future: 4,5,1,3,2. Next use: 4(pos 9), 5(pos 10), 1(pos 11). Furthest is 1. Optimal replaces 1. Matches table.
    4. Ref 1 (2nd): Frames {6,4,5}. Future: 3,2. None of {6,4,5} are used. Optimal can replace any. Table replaces 4. Valid.
    5. Ref 3: Frames {6,1,5}. Future: 2. None used. Optimal can replace any. Table replaces 5. Valid.
    6. Ref 2: Frames {6,1,3}. Future: none. Optimal can replace any. Table replaces 1. Valid.

    Only Optimal is consistent with all replacements.

    Learning route:

    This is a page replacement policy deduction question. We are given the exact state of the frames after each reference and must determine which policy could produce this sequence.

    We test each candidate policy against the critical replacement decisions (marked with *).

    • At reference 4, frames are {1, 2, 3}. The table shows 2 is replaced.
    • LRU would replace 1 (least recently used). This contradicts the table.
    • Optimal looks at the future string: 5, 4, 1, 6, 4, 5, 1, 3, 2. Page 1 is used at index 7, page 3 at index 12, and page 2 at index 13. Since 2 is used furthest in the future, Optimal replaces 2. This matches the table.
    • At reference 5, frames are {1, 4, 3}. The table shows 3 is replaced.
    • Optimal future: 4, 1, 6, 4, 5, 1, 3, 2. Page 4 is used at index 6, page 1 at index 7, page 3 at index 12. Furthest is 3. Optimal replaces 3. Matches.
    • At reference 6, frames are {1, 4, 5}. The table shows 1 is replaced.
    • Optimal future: 4, 5, 1, 3, 2. Page 4 is used at index 4, page 5 at index 5, page 1 at index 6. Furthest is 1. Optimal replaces 1. Matches.
    • For subsequent replacements (references 1, 3, 2), the pages in memory are never used again in the remaining string. Optimal allows replacing any of them, so the table's choices are valid.

    Since LRU, LFU, and MFU fail at the early critical steps, only Optimal is possible.

    Question 5 · Operating System · 2025_Set1 MCQ

    Consider a demand paging memory management system with 32-bit logical address, 20-bit physical address, and page size of 2048 bytes. Assuming that the memory is byte addressable, what is the maximum number of entries in the page table?

    1. A.

    2. B.

    3. C.

    4. D.

    Correct Answer:

    A

    Step-by-Step Solution

    Insight: The number of entries in a page table is determined solely by the size of the logical (virtual) address space and the page size, not the physical address space.

    Exam route:

    1. Logical address = 32 bits.
    2. Page size = 2048 bytes = 2^11 bytes.
    3. Number of pages = Logical address space / Page size = 2^32 / 2^11 = 2^21.
    4. Therefore, the page table must have 2^21 entries.

    Learning route:

    A page table must be capable of mapping every possible virtual page, regardless of whether it is currently resident in physical memory or even allocated.

    The total number of virtual pages is the total logical address space divided by the page size.

    Logical address space = 2^32 bytes.

    Page size = 2048 bytes = 2^11 bytes.

    Number of virtual pages = 2^32 / 2^11 = 2^(32-11) = 2^21.

    Each virtual page requires exactly one entry in the page table. Thus, the maximum number of entries is 2^21.

    The 20-bit physical address is a distractor; it determines the size of the frame number stored in each entry, not the number of entries.

    Question 6 · Operating System · 2025_Set1 NAT
    In optimal page replacement algorithm, information about all future page references is available to the operating system (OS). A modification of the optimal page replacement algorithm is as follows:

    The OS correctly predicts only up to next 4 page references (including the current page) at the time of allocating a frame to a page.

    A process accesses the pages in the following order of page numbers:


    If the system has three memory frames that are initially empty, the number of page faults that will occur during execution of the process is ________. (Answer in integer)
    Correct Answer:

    6.00

    Step-by-Step Solution

    Insight: The modified optimal algorithm looks ahead only 4 references. We must evaluate eviction candidates based solely on their next occurrence within this 4-reference window.

    Exam route:

    Trace the reference string: 1, 3, 2, 4, 2, 3, 1, 2, 4, 3, 1, 4 with 3 frames.

    • 1: Fault. Frames: [1]
    • 3: Fault. Frames: [1, 3]
    • 2: Fault. Frames: [1, 3, 2]
    • 4: Fault. Lookahead (next 4): 2, 3, 1, 2. In memory {1, 3, 2}, page 1 is furthest (at pos 3). Evict 1. Frames: [4, 3, 2].
    • 2: Hit.
    • 3: Hit.
    • 1: Fault. Lookahead (next 4): 2, 4, 3, 1. In memory {4, 3, 2}, page 3 is furthest (at pos 3). Evict 3. Frames: [4, 1, 2].
    • 2: Hit.
    • 4: Hit.
    • 3: Fault. Lookahead (next 4, only 2 left): 1, 4. In memory {4, 1, 2}, page 2 is not in lookahead. Evict 2. Frames: [4, 1, 3].
    • 1: Hit.
    • 4: Hit.

    Total faults = 6.

    Learning route:

    Standard Optimal looks at the entire future. This variant restricts the view to a window of 4 references (including the current one).

    When a page fault occurs and frames are full, we examine the pages currently in memory. We look at the next 4 references. The page whose next occurrence is furthest away within this window (or absent from the window entirely) is the best candidate for eviction.

    Step-by-step:

    1. Ref 1, 3, 2: All faults. Frames = {1, 3, 2}. (3 faults)
    2. Ref 4: Fault. Window = [4, 2, 3, 1]. Candidates in memory: 1, 3, 2. Next uses in window: 2 (idx 1), 3 (idx 2), 1 (idx 3). Furthest is 1. Evict 1. Frames = {4, 3, 2}. (4 faults)
    3. Ref 2, 3: Hits.
    4. Ref 1: Fault. Window = [1, 2, 4, 3]. Candidates: 4, 3, 2. Next uses: 2 (idx 1), 4 (idx 2), 3 (idx 3). Furthest is 3. Evict 3. Frames = {4, 1, 2}. (5 faults)
    5. Ref 2, 4: Hits.
    6. Ref 3: Fault. Window = [3, 1, 4]. Candidates: 4, 1, 2. Next uses: 1 (idx 1), 4 (idx 2). Page 2 is absent. Evict 2. Frames = {4, 1, 3}. (6 faults)
    7. Ref 1, 4: Hits.

    Total = 6 faults.

    Question 7 · Operating System · 2024_Set2 NAT
    Consider a 32-bit system with 4 KB page size and page table entries of size 4 bytes each. Assume 1 KB = 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 __________
    Correct Answer:

    1028.00

    Step-by-Step Solution

    Insight: The minimum number of pages occurs when accessed pages are packed densely into inner page tables; the maximum occurs when they are spread as sparsely as possible, bounded by the outer page table's capacity.

    Exam route:

    1. Page size = 4 KB, PTE = 4 B. Entries per page table page = 4096 / 4 = 1024.
    2. Outer page table has 1024 entries, fitting exactly in 1 page (allocated at creation).
    3. Min inner pages for 2000 accesses: ceil(2000 / 1024) = 2. Total = 1 + 2 = 3.
    4. Max inner pages for 2000 accesses: bounded by outer page table entries = 1024. Total = 1 + 1024 = 1025.
    5. X + Y = 3 + 1025 = 1028.

    Learning route:

    This is a sparse address space multi-level allocation question.

    Step 1: Determine the capacity of a single page table page. With a 4 KB page size and 4-byte PTEs, each page table page holds 4096 / 4 = 1024 entries.

    Step 2: The outer page directory is allocated entirely upon process creation. Since it must index the remaining 20 bits of the 32-bit virtual address (after 12 bits for offset), it needs 2^10 = 1024 entries, which fits exactly in 1 page.

    Step 3: Calculate the minimum number of inner page tables (X). To minimize overhead, we pack the 2000 accessed unique pages as densely as possible. Each inner page table holds 1024 entries. We need ceil(2000 / 1024) = 2 inner page tables. Total pages = 1 (outer) + 2 (inner) = 3.

    Step 4: Calculate the maximum number of inner page tables (Y). To maximize overhead, we spread the 2000 accessed pages as sparsely as possible. However, the outer page table only has 1024 entries, meaning it can point to at most 1024 inner page tables. Thus, the maximum number of inner page tables is 1024. Total pages = 1 (outer) + 1024 (inner) = 1025.

    Step 5: X + Y = 3 + 1025 = 1028.

    Question 8 · Operating System · 2024_Set2 MSQ

    Which of the following tasks is/are the responsibility/responsibilities of the memory management unit (MMU) in a system with paging-based memory management?

    1. A.

      Allocate a new page table for a newly created process

    2. B.

      Translate a virtual address to a physical address using the page table

    3. C.

      Raise a trap when a virtual address is not found in the page table

    4. D.

      Raise a trap when a process tries to write to a page marked with read-only permission in the page table

    Correct Answer:

    ["B","C","D"]

    Step-by-Step Solution

    Insight: The MMU is a hardware component responsible for address translation and protection checks, not OS-level memory allocation.

    Exam route: Evaluate each option based on the hardware (MMU) vs. software (OS) boundary.

    Learning route:

    1. Option A: Allocating a page table is a software task performed by the OS during process creation. The MMU only reads the page table base register (PTBR).
    2. Option B: The core function of the MMU is to translate virtual addresses to physical addresses using the page table.
    3. Option C: If the valid bit in the PTE is 0, the MMU hardware triggers a page fault trap to the OS.
    4. Option D: If a write operation is attempted on a page with the read-only protection bit set, the MMU hardware triggers a protection fault trap.

    Thus, B, C, and D are hardware responsibilities of the MMU.

    Question 9 · Operating System · 2024_Set1 NAT

    Consider a memory management system that uses a page size of 2 KB. Assume that both the physical and virtual addresses start from 0. Assume that the pages 0, 1, 2, and 3 are stored in the page frames 1, 3, 2, and 0, respectively. The physical address <i>(in decimal format)</i> corresponding to the virtual address 2500 <i>(in decimal format)</i> is _________

    Correct Answer:

    6596.00

    Step-by-Step Solution

    Insight: Physical address is calculated by replacing the virtual page number with the corresponding physical frame number while keeping the offset unchanged.

    Exam route:

    1. Page size = 2 KB = 2048 bytes.
    2. Virtual address = 2500.
    3. Virtual page number = 2500 / 2048 = 1.
    4. Offset = 2500 % 2048 = 452.
    5. Page 1 maps to frame 3.
    6. Physical address = (3 * 2048) + 452 = 6144 + 452 = 6596.

    Learning route:

    This is a single-level address translation arithmetic question.

    Step 1: Identify the page size. Here, it is 2 KB, which is 2048 bytes.

    Step 2: Split the virtual address into the virtual page number (VPN) and the offset.

    VPN = floor(Virtual Address / Page Size) = floor(2500 / 2048) = 1.

    Offset = Virtual Address % Page Size = 2500 % 2048 = 452.

    Step 3: Look up the physical frame number for VPN 1. The problem states that page 1 is stored in frame 3.

    Step 4: Construct the physical address. The physical address is formed by concatenating the physical frame number with the original offset.

    Physical Address = (Frame Number * Page Size) + Offset

    Physical Address = (3 * 2048) + 452 = 6144 + 452 = 6596.

    Question 10 · Operating System · 2023 NAT
    Consider the following two-dimensional array D in the C programming language, which is stored in row-major order:

    int D[128][128];

    Demand paging is used for allocating memory and each physical page frame holds 512 elements of the array D. The Least Recently Used (LRU) page-replacement policy is used by the operating system. A total of 30 physical page frames are allocated to a process which executes the following code snippet:

    for (int i = 0; i < 128; i++)
       for (int j = 0; j < 128; j++)
          D[j][i] *= 10;

    The number of page faults generated during the execution of this code snippet is __________.
    Correct Answer:

    4096.00

    Step-by-Step Solution

    Insight: Column-major traversal of a row-major 2D array destroys spatial locality, causing a page fault for nearly every new page touched, especially when the working set exceeds available frames.

    Exam route:

    1. Array size = 128 * 128 = 16384 elements.
    2. Elements per page = 512. Total pages = 16384 / 512 = 32 pages.
    3. The nested loops access D[j][i], which is column-major traversal.
    4. For a fixed column i, the inner loop accesses 128 elements with a stride of 128.
    5. This touches exactly 32 distinct pages per column.
    6. Since only 30 frames are available, every new page in the sequence of 32 causes a fault.
    7. Faults per column = 32. Total faults = 128 columns * 32 = 4096.

    Learning route:

    This is a classic 2D array access pattern question. The array is stored in row-major order, meaning elements of the same row are contiguous in memory.

    The code uses D[j][i] with i in the outer loop and j in the inner loop. This is column-major traversal.

    For a fixed i, as j goes from 0 to 127, the 1D index is j * 128 + i.

    The page number for each access is floor((j * 128 + i) / 512).

    Since i < 128, the page number increments by 1 every time j increases by 4 (because 4 * 128 = 512).

    Thus, the inner loop touches exactly 128 / 4 = 32 distinct pages.

    The sequence of pages accessed in one inner loop is 0, 0, 0, 0, 1, 1, 1, 1, ..., 31, 31, 31, 31.

    The system has 30 page frames. When the inner loop requests page 30, it faults and evicts page 0. When it requests page 31, it faults and evicts page 1.

    Therefore, every single inner loop execution causes exactly 32 page faults.

    There are 128 iterations of the outer loop, so total page faults = 128 * 32 = 4096.

    More previous year questions (pyqs) in this unit