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
- Program for Least Recently Used (LRU) Page Replacement algorithm
- Optimal Page Replacement Algorithm
- Belady's Anomaly in Page Replacement Algorithms
- Second Chance (or Clock) Page Replacement Policy
- Page Replacement Algorithms in Operating Systems
- Program for Page Replacement Algorithms | Set 2 (FIFO)
- Peterson's Algorithm for Mutual Exclusion | Set 1 (Basic C implementation)
- Kruskal's Algorithm (Simple Implementation for Adjacency Matrix)
- Prim's Algorithm (Simple Implementation for Adjacency Matrix Representation)
- Page Table Entries in Page Table
- Minimize Cost with Replacement with other allowed
- Program for Banker's Algorithm | Set 1 (Safety Algorithm)
- Inverted Page Table in Operating System
- Page Fault Handling in Operating System
- Least Frequently Used (LFU) Cache Implementation
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.