Least Frequently Used (LFU) Page Replacement Algorithm
Least Frequently Used (LFU) Page Replacement Algorithm
1. Aim
To implement the Least Frequently Used (LFU) Page Replacement Algorithm and display the frame contents after each page reference.
2. Objective
-
To understand the working of LFU page replacement
-
To replace the page with the minimum access frequency
-
To analyze page hits and page faults
3. Theory
The LFU algorithm replaces the page that has been used least often.
Key Idea:
“Pages with low access frequency are less likely to be used again.”
When two pages have the same frequency, FIFO order (or oldest) is commonly used as a tie-breaker.
4. Data Structures Used
| Structure | Purpose |
|---|---|
frames[] | Stores pages in memory |
freq[] | Stores access frequency |
time[] | Stores arrival time (tie-breaker) |
counter | Global time counter |
5. Algorithm
-
Initialize frames as empty
-
For each page reference:
-
If page exists → Hit, increment frequency
-
Else:
-
If empty frame exists → insert page
-
Else → replace page with lowest frequency
-
If tie → replace oldest page
-
-
-
-
Display frame contents after each step
-
Count page faults
6. C Program (LFU)
7. Sample Input
8. Sample Output (Frame Table)
9. Observations
-
LFU considers frequency instead of recency
-
Tie-breaking is required ( use FIFO)
-
Performance depends on access pattern
10. Advantages
✔ Useful for workloads with repeated access
✔ Avoids replacing frequently used pages
11. Disadvantages
❌ Old pages may remain forever (frequency aging problem)
❌ More overhead than FIFO
❌ Requires tie-breaking strategy
12. Result
The LFU page replacement algorithm was successfully implemented using a C program, and the frame contents were displayed after each page reference.
Comments
Post a Comment