In the Least Recently Used (LRU) page replacement policy,
the page that is used least recently will be replaced.
Implementation:
Add a register to every page frame - contain the last time
that the page in that frame was accessed
Use a "logical clock" that advance by 1 tick
each time a memory reference is made.
Each time a page is referenced, update its register
The following figure shows the behavior of the program
in paging using the LRU page replacement policy:
We can see notably that the bad replacement decisions made
by FIFO is not present in LRU.
There are a total of 9 page read operations to satisfy
the total of 18 page requests - that is almost a 20% improvement
over FIFO in such a short
experiment
(I only want to make the point here that page replacement policy
can affect the system performance.
I do not want to get into the question of "how much better is
LRU than FIFO").
In fact, it has been shown empirically that LRU is
the preferred page replacement policy
Disadvantage of LRU replacement policy:
To identify the page to replace, you need to find
the minimum time stamp value in all the registers...
Lots of work...
There is a more efficient scheme that approximate
the behavior of LRU that runs more efficiently...