Open In App

Not Recently Used (NRU) page replacement algorithm

It is a page replacement algorithm. This algorithm removes a page at random from the lowest numbered non-empty class. Implicit in this algorithm is that it is better to remove a modified page that has not been referenced in atleast one clock tick than a clean page that is in heavy use. It is easy to understand, moderately efficient to implement and gives a performance that while certainly not optimal, may be adequate. When page is modified, a modified bit is set. When a page needs to be replaced, the Operating System divides pages into 4 classes.

Not Recently Used (NRU) is a page replacement algorithm used in operating systems to determine which page to replace in memory when a page fault occurs. The NRU algorithm divides pages into four categories based on their usage history, and selects a page for replacement from the category with the lowest priority. The four categories are:



  1. Category 0: Pages that have not been referenced and modified recently
  2. Category 1: Pages that have not been referenced recently but have been modified recently
  3. Category 2: Pages that have been referenced recently but have not been modified recently
  4. Category 3: Pages that have been referenced and modified recently

When a page fault occurs, the NRU algorithm scans the pages in memory and identifies the pages in each category. It then selects a random page from the lowest category with non-empty pages and replaces it with the new page. This ensures that pages that are least likely to be needed in the future are replaced first, and the algorithm tries to avoid replacing pages that have been accessed recently.

One of the main advantages of the NRU algorithm is its simplicity and low overhead, as it only requires a single bit for each page to track its usage history. However, the NRU algorithm can be suboptimal in some situations, as it does not take into account the frequency of page accesses or the size of pages. In addition, the random selection of pages from each category can lead to non-uniform replacement rates, where some pages are replaced more frequently than others.



Out of above 4 categories, NRU will replace a Not Referenced, Not Modified page, if such page exists. Note that this algorithm implies that a Modified but Not Referenced is less important than a Not Modified and Referenced. Example –

Page Referenced Modified
0 1 0
1 0 1
2 0 0
3 1 1

Algorithm : From the given reference string NRU will remove a page at random from the lowest numbered nonempty class. Implicit in this algorithm is that it is better to remove a modified page that has not been referenced in at least one clock tick (typically 20 msec) than a clean page that is in heavy use. Example –

Article Tags :