Prerequisite – Least Recently Used (LRU) Page Replacement algorithm
Least Recently Used page replacement algorithm replaces the page which is not used recently.
In this article, LRU is implemented using counters, a ctime (i.e., counter) variable is used to represent the current time, it is incremented for every page of the reference array. A vector of pair is used to represent the page frames, the 1’st variable of the pair is the page number and the second variable is the current time. When a new page is to be inserted and the frames are full, the page with minimum ctime is deleted (as it is the least recently used page). If the page is accessed again the value of ctime is updated.
Least ctime (counter / current time) value represents the least recently used page.
Reference array is : 0, 0, 0, 2, 3, 0, 5, 7, 1, 2, 0, 8 Output : When the number of frames is : 3 The number of page faults are : 9 Reference array is : 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 0, 0 Output : When the number of frames is : 3 The number of page faults are : 15
The number of page faults is : 10
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.
- Not Recently Used (NRU) page replacement algorithm
- Program for Least Recently Used (LRU) Page Replacement algorithm
- Optimal Page Replacement Algorithm
- Second Chance (or Clock) Page Replacement Policy
- Program for Page Replacement Algorithms | Set 2 (FIFO)
- Page Replacement Algorithms in Operating Systems
- Advantages and Disadvantages of various Page Replacement algorithms
- Belady's Anomaly in Page Replacement Algorithms
- Kruskal's Algorithm (Simple Implementation for Adjacency Matrix)
- Peterson's Algorithm for Mutual Exclusion | Set 1 (Basic C implementation)
- Prim's Algorithm (Simple Implementation for Adjacency Matrix Representation)
- Minimize Cost with Replacement with other allowed
- Page Table Entries in Page Table
- Program for Banker's Algorithm | Set 1 (Safety Algorithm)
- Caching Page Tables
- Inverted Page Table in Operating System
- Page Fault Handling in Operating System
- Hashed Page Tables in Operating System
- Least Frequently Used (LFU) Cache Implementation
- Implementation of Access Matrix in Distributed OS
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.