Engineering End Semester Examination
– Valuation Answer Key
Subject: Operating Systems
Question Type: 16 Marks
Question: Describe various page replacement algorithms with examples.
1. Introduction to Page Replacement (2 Marks)
- Page replacement occurs when a page fault happens and there are no free frames.
- The operating system must select a page to remove to load the new page.
2. Page Replacement Algorithms (10 Marks)
i. First-In First-Out (FIFO) (2 Marks)
- Replaces the oldest page in memory.
- Simple to implement.
Example (Page reference string: 1, 2, 3, 1, 4, 5; 3 frames):
1 → [1]
2 → [1, 2]
3 → [1, 2, 3]
1 → Hit
4 → Replace 1 → [4, 2, 3]
5 → Replace 2 → [4, 5, 3]
Page Faults = 5
ii. Least Recently Used (LRU) (2 Marks)
- Replaces the page that has not been used for the longest time.
Example (Page reference string: 1, 2, 3, 1, 4, 5; 3 frames):
1 → [1]
2 → [1, 2]
3 → [1, 2, 3]
1 → Hit
4 → Replace 2 → [1, 4, 3]
5 → Replace 3 → [1, 4, 5]
Page Faults = 5
iii. Optimal Page Replacement (2 Marks)
- Replaces the page that will not be used for the longest time in future.
- Theoretical best.
Example (Page reference string: 7, 0, 1, 2, 0, 3, 0, 4; 3 frames):
7 → [7]
0 → [7, 0]
1 → [7, 0, 1]
2 → Replace 7 → [2, 0, 1]
0 → Hit
3 → Replace 1 → [2, 0, 3]
0 → Hit
4 → Replace 2 → [4, 0, 3]
Page Faults = 6
iv. LFU & MRU (2 Marks)
- LFU (Least Frequently Used): Replaces the page with lowest access count.
- MRU (Most Recently Used): Replaces the most recently accessed page.
- Useful in specific workloads but not always efficient.
3. Comparison Table (2 Marks)
Algorithm Basis Advantage Disadvantage
FIFO Oldest page Simple May remove
frequently used
pages
LRU Least recently used Better than FIFO Needs tracking
Optimal Future access Minimum page Not practical
faults
LFU Access frequency Good for repeated Expensive to
use maintain counters
MRU Recent access Efficient in few Poor in general use
cases
4. Conclusion (2 Marks)
- Page replacement is crucial in managing memory efficiently in virtual memory systems.
- Optimal is ideal but impractical. LRU is widely used in real-world systems.