RTUComputer ScienceYr 2023 · Sem 52023

Q5Operating System

Question

4 marks

Explain the concept of Page Replacement algorithms.

Answer

A detailed exploration of Page Replacement algorithms, critically analyzing FIFO's simplicity and Belady's Anomaly against the strict mathematical superiority of the LRU algorithm.

In a Virtual Memory architecture, the OS aggressively executes programs larger than physical RAM by mapping logical Pages to physical RAM Frames. However, when physical RAM is 100% completely full, and the CPU violently demands a new page from the Hard Drive (a Page Fault), the OS must execute a catastrophic decision: It must select an existing, highly utilized page currently residing in RAM, rip it out, violently evict it back to the slow Hard Drive, and load the new page. The mathematical logic determining WHICH page gets evicted is the Page Replacement Algorithm.

1. First-In, First-Out (FIFO)

The most primitive, mathematically basic algorithm. - Mechanism: The OS maintains a strict queue. The page that physically entered the RAM the earliest (the oldest page) is the one violently evicted. - Demerit (Belady's Anomaly): FIFO suffers from a catastrophic mathematical paradox known as Belady's Anomaly. Logically, adding more physical RAM should decrease Page Faults. However, in specific FIFO scenarios, physically increasing the RAM size mathematically causes MORE Page Faults to occur, completely destroying performance.

2. Least Recently Used (LRU)

The absolute industry standard algorithm, relying on the mathematical principle of Temporal Locality. - Mechanism: The OS aggressively tracks the exact microsecond every single page was last read or written to by the CPU. When an eviction is mandatory, the OS violently hunts down the specific page that has not been touched for the longest period of time (the Least Recently Used) and evicts it. - Merit: It is mathematically immune to Belady's Anomaly and provides incredibly optimal performance because code executed recently is highly likely to be executed again.

Back to Paper