# 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.

**0:-**Not Referenced, Not Modified**1:-**Not Referenced, Modified**2:-**Referenced, Not Modified**3:-**Referenced, Modified

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 |

- Case-1 implies to Not Referenced and Modified.
- Case-2 implies to Not Referenced and Not Modified.
- Case-3 implies to Referenced and Modified.
- Case-0 implies to Referenced and Not Modified.

**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 –**

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: **DSA Self Paced**. Become industry ready at a student-friendly price.

## Recommended Posts:

- Peterson's Algorithm for Mutual Exclusion | Set 1 (Basic C implementation)
- Peterson's Algorithm for Mutual Exclusion | Set 2 (CPU Cycles and Memory Fence)
- Program for Banker's Algorithm | Set 1 (Safety Algorithm)
- Page Replacement Algorithms in Operating Systems
- Banker's Algorithm in Operating System
- Program for Least Recently Used (LRU) Page Replacement algorithm
- Peterson's Algorithm in Process Synchronization
- Program for SSTF disk scheduling algorithm
- Program for Next Fit algorithm in Memory Management
- C-SCAN Disk Scheduling Algorithm
- Page Fault Handling in Operating System
- Page Table Entries in Page Table
- Optimal Page Replacement Algorithm
- Banker's Algorithm in Operating System
- Dekker's algorithm in Process Synchronization
- Bakery Algorithm in Process Synchronization
- Belady's Anomaly in Page Replacement Algorithms
- Inverted Page Table in Operating System
- Deadlock Detection Algorithm in Operating System
- Longest Remaining Time First (LRTF) CPU Scheduling Algorithm

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.