The Least Recently Used (LRU) algorithm replaces the page that has not been used for the longest period of time when a new page needs to be loaded and all frames are full.
How it works:
- When a page is referenced, it's checked if it's already in memory.
- If the page is in memory, it's marked as "most recently used".
- If not in memory and there's a free frame, the page is loaded there.
- If all frames are full, the least recently used page is replaced.
- The algorithm maintains an ordering of pages by recency of use.
The LRU algorithm performs well in practice but requires additional hardware support to efficiently track page usage.