LRU in JAVA language
Least Recently Used (LRU) Algorithm
In memory management, page replacement algorithms play a very vital part of keeping the main memory filled with fresh pages. One of the algorithms called Least Recently Used (LRU) page replacement algorithm works on the concept that it replaces those pages first which are the oldest and have been least referred.
LRU in Java Language
To implement this, a counter called an “age bit” is maintained, which keeps track of which page is to be referred and when it is to be referred. It ensures that the page which was least recently used is discarded to make space for the new page. When the page requested by the user is not present in the RAM, then a page fault occurs. When the page requested by the user is already present in the RAM, then page hit occurs. Let us understand LRU with an example.
Reference String = 7 0 1 2 0 3 0 4 2 3
Number of iteration = 10
Page frame = 3
Number of page fault = 8
Number of page hit = 2
Read Also – LRU in python language
LRU Program in Java