Page Replacement Algorithm Fundamentals: FIFO, LRU, and Optimal Quiz

Explore key concepts and scenarios related to FIFO, LRU, and Optimal page replacement algorithms. Enhance your understanding of how these strategies manage memory pages and minimize page faults in operating systems.

  1. Identifying FIFO

    Which page replacement algorithm replaces the oldest page in memory first?

    1. FILO
    2. LRU
    3. Optimal
    4. FIFO

    Explanation: FIFO, or First-In First-Out, always replaces the page that has been in memory the longest. LRU looks for the least recently used page, not necessarily the oldest. Optimal replaces the page that will not be needed for the longest time in the future. FILO stands for First-In Last-Out, which is not used in page replacement.

  2. Understanding LRU Method

    When a page fault occurs, which strategy does the Least Recently Used (LRU) algorithm follow?

    1. Removes a random page
    2. Removes the page that entered memory earliest
    3. Removes the page that was used farthest in the past
    4. Removes the page that will not be used soonest

    Explanation: LRU targets the page that hasn't been accessed for the longest period. Removing the page that entered first is FIFO's approach, not LRU's. Optimal uses the future reference pattern, while random removal does not define any standard method.

  3. Optimal Algorithm Scenario

    Given the future reference string [3, 4, 5, 3, 2] with limited frames, which page replacement algorithm uses future knowledge to minimize faults?

    1. Advanced FIFO
    2. Optimal
    3. FIFO
    4. LIFO

    Explanation: The Optimal algorithm predicts future requests to select which page to evict and achieves the lowest possible page faults. FIFO and LIFO do not use future knowledge. 'Advanced FIFO' is not a standard page replacement method.

  4. Algorithm Performance

    Which algorithm typically results in the least number of page faults for a given page reference string?

    1. Optimal
    2. RANDOM
    3. FIFO
    4. LRU

    Explanation: The Optimal algorithm ensures the minimum number of faults by removing the page not needed for the longest time. FIFO and LRU usually cause more faults because they lack future knowledge. RANDOM can sometimes perform poorly since it does not use any access pattern.

  5. LRU Example

    Using the LRU algorithm, which page gets replaced if memory holds pages [1, 2, 3] and 2 was accessed most recently?

    1. 2
    2. 1
    3. 3
    4. 4

    Explanation: LRU replaces the least recently used page, which in this case is page 1. Page 2 is the most recently accessed and will not be replaced. Page 3 is more recently used than 1, while page 4 isn't in memory yet and thus can't be replaced.

  6. FIFO Drawback

    What is a known drawback of the FIFO page replacement algorithm?

    1. It always needs future reference knowledge.
    2. It may remove frequently used pages.
    3. It is impossible to implement.
    4. It never causes page faults.

    Explanation: FIFO may choose to evict pages that are still heavily used just because they were loaded earlier. It doesn't require information about future references, so option two is incorrect. Option three is false, as FIFO does cause page faults. The algorithm is simple to implement, invalidating option four.

  7. Optimal Limitation

    Why can't the Optimal page replacement algorithm be used in a typical, real operating system?

    1. It works only with FIFO buffers.
    2. It requires knowledge of future memory accesses.
    3. It increases the number of page faults.
    4. It uses too much RAM.

    Explanation: Optimal is theoretical because it needs future access patterns, which aren't available in real time. It doesn't necessarily use more RAM than other algorithms. It is independent of FIFO buffers and is designed to minimize page faults, not increase them.

  8. FIFO vs LRU Difference

    How does LRU primarily differ from FIFO in deciding which page to replace?

    1. It replaces the oldest page by access time, not arrival time.
    2. It replaces any random page.
    3. It always replaces the first page loaded.
    4. It replaces the page with the lowest number.

    Explanation: LRU looks at when each page was last used, so it removes the least recently accessed. Replacing by page number is unrelated. FIFO always replaces the first loaded page by arrival time, and random replacement is not LRU or FIFO.

  9. Reference String Impact

    If a reference string repeatedly requests the same page, how many faults should FIFO, LRU, and Optimal have after the first access?

    1. Zero page faults after the first access
    2. Same number of faults as the page requests
    3. Faults only for FIFO and LRU, but not Optimal
    4. One fault for each algorithm after each access

    Explanation: After the page is loaded once, it stays in memory, so no further faults occur for repeated accesses regardless of algorithm. More faults can't occur unless the page leaves memory. The other options incorrectly suggest persistent faults or differences in behavior among algorithms.

  10. Practical Application

    Which page replacement algorithm is often chosen in practice because it is both effective and implementable without knowing future references?

    1. LRU
    2. RANDOM
    3. Least Inserted
    4. Optimal

    Explanation: LRU is praised for closely approximating optimal performance while being feasible to implement, as it uses past reference patterns rather than the future. The Optimal algorithm, while most effective in theory, isn't practical due to the need for future knowledge. RANDOM does not perform consistently well, and 'Least Inserted' is not a standard method.