LRU page replacement links with all pages the time of that page’s last use. At the point when a page must be replaced with LRU page replacement picks the page that has not been utilized for the longest time frame. We can think about this technique as the optimal page-replacement algorithm glancing in reverse in time, as opposed to advance.
In Least Recently Used (LRU) algorithm is a Greedy algorithm where the page to be replaced is least recently used. The idea is based on locality of reference, the least recently used page is not likely.
Example:
•Consider the page reference string 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2 with 4 page frames.Find number of page faults.
Initially all slots are empty, so when 7 0 1 2 are allocated to the empty slots —> 4 Page faults
0 is already there so —> 0 Page fault.
when 3 came it will take the place of 7 because it is least recently used —>1 Page fault
0 is already there so —> 0 Page fault.
4 will takes place of 1 —> 1 Page Fault.
Now for the further page reference string —> 0 Page fault because they are already available in the memory.
Advantage:
It is amenable to full statistical examination.
This algorithm is very efficient.
It never suffers from Belady’s anomaly.
Disadvantage:
Its execution is bit complicated.
Its execution may need substantial hardware assistance.