Least Recently Used (LRU) in C
Least Recently Used (LRU) Algorithm
The operating system uses a set of instructions to execute different programs. These instructions are present in blocks of data called pages. The operating system uses these pages to fetch data and instructions. In most of the cases, it is said that pages that have been heavily used during information processing, will again be used in the next few instructions.
Therefore, the operating system removes the unused pages from the main memory and sends them to the secondary memory. The concept behind this is, the pages that have not been used in the processing, will not be used in the next few instructions.
The operating system implements the page fault mechanism through an algorithm. This algorithm maintains a linked list of all the pages in the memory. The most recently used pages are kept in the front, while the pages which are not used are placed at the rear position. It generates the need of page replacement algorithm which can lessen the waiting time for pages in. The Least Recently Used (LRU) page replacement algorithm, needs to decide which page is to be replaced when the new page comes in.
Read Also – LRU in C ++