LRU Page Replacement Algorithm in C

Here you will get program for lru page replacement algorithm in C.

Least Recently Used (LRU) page replacement algorithm works on the concept that the pages that are heavily used in previous instructions are likely to be used heavily in next instructions. And the page that are used very less are likely to be used less in future. Whenever a page fault occurs, the page that is least recently used is removed from the memory frames. Page fault occurs when a referenced page in not found in the memory frames.

Also Read: LRU Page Replacement Algorithm in C

Below program shows how to implement this algorithm in C.

Program for LRU Page Replacement Algorithm in C

Output

Enter number of frames: 3
Enter number of pages: 6
Enter reference string: 5 7 5 6 7 3

5 -1 -1
5 7 -1
5 7 -1
5 7 6
5 7 6
3 7 6

Total Page Faults = 4

Video Tutorial

Comment below if you have doubts or found anything incorrect in above lru page replacement algorithm in C.

Leave a Reply

Your email address will not be published. Required fields are marked *