Page Replacement Algorithm Simulator
Type a reference string and frame count to get the frame table, faults, hits and victims for four algorithms, a comparison across frame counts and a Belady's anomaly chart.
브라우저에서 실행됩니다. 파일은 기기 밖으로 나가지 않습니다. 확인하는 방법 보기
…
사용 방법
- 1Enter the reference string
Type page numbers separated by spaces or commas.
- 2Set the frames
Choose the number of frames from 1 to 10.
- 3Pick an algorithm
Press FIFO, LRU, OPT or CLOCK to see the frame-by-frame table.
- 4Read the results
Check faults, hits and the hit ratio, and the evicted page under each fault.
- 5Compare and explore
Use Compare for all frame counts and Belady's anomaly for the faults-versus-frames chart.
- 6Practise and export
Answer generated questions, export the table as CSV or print it.
이 도구 소개
When a program needs a page that is not in main memory, the operating system must load it, and if memory is full it must decide which page to throw out. That decision is the page-replacement algorithm, and comparing algorithms on a reference string is a classic operating-systems exercise. Students draw a grid with one column per memory reference and one row per frame, mark each page fault and count them. This simulator draws the same grid for FIFO, LRU, the optimal algorithm and the Clock (second-chance) algorithm. It marks faults and hits, shows which page was replaced at each step and the use bits for Clock, compares all four algorithms for one to seven frames and plots faults against frames so you can see Belady's anomaly.
The four algorithms
- **FIFO** replaces the page that has been in memory longest. Easy to implement with a queue, but it may throw out a page that is used constantly. - **LRU** replaces the page that has not been used for the longest time. It approximates the future with the recent past and usually performs well. - **Optimal (OPT or MIN)** replaces the page that will not be used for the longest time in the future. It gives the minimum number of faults possible but needs knowledge of the future, so it serves as a benchmark. - **Clock** keeps pages in a circle with a use bit. The hand passes over pages whose bit is 1, clearing it, and replaces the first page whose bit is 0. It is a cheap approximation of LRU used in real systems.
Reading the table
Each column is one memory reference. The rows show the pages in each frame after that reference. A red cell marks where a page was loaded on a fault, the row below shows F for a fault and ✓ for a hit, and the bottom row shows the page that was evicted. The figures above give the number of faults, hits and the hit ratio (hits ÷ references).
Belady's anomaly
You would expect more frames to mean fewer faults. For FIFO that is not guaranteed: with the reference string 1 2 3 4 1 2 5 1 2 3 4 5, FIFO causes 9 faults with three frames but 10 with four. László Bélády and colleagues described this in 1969. LRU and the optimal algorithm are stack algorithms, so they can never show the anomaly. The Belady tab plots faults against frames for all four algorithms and points out any increase.
Worked example
The textbook string 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1 with three frames gives 15 faults with FIFO, 12 with LRU and 9 with the optimal algorithm. With LRU the first fault after the frames fill comes at page 2, which replaces 7 because 7 was used longest ago.
Limits
The simulator models a single process with pure demand paging and no dirty-page or write-back costs. Real systems use variants such as two-handed clocks, working-set policies and page buffering. Results show the number of faults, not their time cost.
풀이 예시
7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1, three frames: FIFO 15, LRU 12, Optimal 9 faults.
한눈에 보기
- 카테고리: 개발 및 데이터
- 브라우저에서 실행되며 가입도 업로드도 필요 없습니다.
- 입력한 정보는 기기에 머뭅니다.
- 영어로 제공됩니다.
- 콘텐츠 최종 검토일:
- 공식 출처: Silberschatz et al., Operating System Concepts, chapter 10; Belady, Nelson and Shedler (1969)
자주 묻는 질문
What is a page fault?
A reference to a page that is not currently in a memory frame, so it must be loaded from disk.
Why is the optimal algorithm not used in practice?
It needs to know which pages will be used in the future, which an operating system cannot know. It is used to measure how good other algorithms are.
What is Belady's anomaly?
For some algorithms, such as FIFO, adding frames can increase the number of page faults for a particular reference string.
How does the Clock algorithm work?
Each frame has a use bit set when the page is referenced. The clock hand clears bits of 1 as it passes and replaces the first page with a bit of 0.
How do I count faults when frames start empty?
Every first reference to a page fills an empty frame and counts as a fault (a compulsory miss). The simulator includes these.
Can I use my own reference string?
Yes. Type any page numbers separated by spaces or commas, or press Random string.
