How to use the Page Replacement Algorithm Simulator
- 1. Enter the reference stringPage numbers separated by spaces.
- 2. Set frames and algorithm1 to 10 frames; FIFO, LRU, Optimal, LFU or Clock.
- 3. Read the tableEvery column shows the frames after that reference, with faults marked.
The algorithms
- FIFO: replace the page that has been in memory longest. Simple, but it can suffer Belady's anomaly, where more frames give more faults.
- LRU (least recently used): replace the page unused for the longest time. Good in practice; needs tracking of use order.
- Optimal (OPT): replace the page that won't be used for the longest time in the future. The fewest faults possible, but it needs to know the future, so it's used only as a benchmark.
- LFU: replace the least frequently used page (ties go to the oldest).
- Clock (second chance): a cheap approximation of LRU using a reference bit and a circular pointer.
The table follows the format exams use: one column per reference, one row per frame, F for a fault and H for a hit, with the new page highlighted.
Worked example
The sample is the classic textbook string 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1 with 3 frames:
- FIFO: 15 page faults (5 hits, hit ratio 25%).
- LRU: 12 faults.
- Optimal: 9 faults.
- LFU: 13 faults; Clock: 14 faults.
These match the standard answers in operating system textbooks, so you can check your homework column by column. To see Belady's anomaly, enter 1 2 3 4 1 2 5 1 2 3 4 5 with FIFO: 3 frames give 9 faults but 4 frames give 10. The tool spots this and warns you whenever FIFO does worse with more frames.
Frequently asked questions
Why is Optimal impossible in a real OS?
It needs to know which pages will be used in future, which the OS can't know in advance.
Does LRU suffer from Belady's anomaly?
No. LRU and Optimal are 'stack algorithms', so more frames never cause more faults.
How are ties broken in LFU?
Among pages with the same count, the one that arrived first is replaced.
Is the page replacement algorithm simulator free to use?
Yes, the page replacement algorithm simulator is free and costs nothing. Your first simulation shows a short form for your name and WhatsApp number one time; once that's done, this tool and every other Uncodemy tool open with no form.