OS | Least Recently Used Page Replacement Algorithm | Exp - 7
Least Recently Used
The Least Recently used (LRU) algorithm replaces the page that has not been used for the longest period of time. It is based on the observation that pages that have not been used for long time will probably remain unused for the longest time and are to be replaced.
Initially, 3 page frames are empty. The first 3 references (7, 0, 1) cause page faults and are brought into these empty frames. The next reference (2) replaces page 7. Since next page reference (0) is already in memory, there is no page fault. Now, for the next reference (3), LRU replacement sees that, of the three frames in memory, page 1 was used least recently, and thus is replaced. And thus the process continues.
Advantages
- LRU page replacement algorithm is quiet efficient.
- It does not suffer from Belady's Anomaly.
Disadvantages
- Its implementation is not very easy.
- Its implementation may require substantial hardware assistance.
No comments: