Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Page Replacement Algorithm Graph Plotter

Interactive visualization of FIFO, LRU, Optimal, LFU and MFU page replacement algorithms.
Built with pure HTML/CSS/JS and Chart.js. Adapted from the Disk Scheduling Algorithm visualizer for OS memory management.

Features

  • 5 Algorithms: FIFO, LRU, Optimal, LFU, MFU.
  • Step-by-Step Simulation: Frame state visualization, per-step table, playback controls (Play/Pause/Next/Prev).
  • Metrics: Page hits, faults, hit ratio, fault ratio, frames used.
  • Graphs: Page Fault Timeline (binary), Frame Utilization over steps.
  • Compare All Mode: Run all algorithms instantly, view comparison bar chart and detailed table.
  • Algorithm Info Cards: Collapsible cards with definition, pros/cons, time & space complexity.
  • Glassmorphism UI: Consistent with the original Disk Scheduling project look and feel.

Usage

  1. Enter a Reference String (comma-separated integers, e.g., 7,0,1,2,0,3,0,4,2,3,0,3,2).
  2. Choose Number of Frames (1-10 recommended).
  3. Pick an Algorithm from the dropdown.
  4. Click Run Simulation to see frame visualization, statistics, and graphs.
  5. Use Play/Pause/Next/Prev to walk through the execution.
  6. Click Compare All to see how all five algorithms perform on the same input.
  7. Expand Algorithm Information cards for theoretical details.

Project Structure

The project follows the exact same single-file architecture as the original Disk Scheduling repository:

  • index.html – Main structure, controls, canvas containers.
  • style.css – Glassmorphism styling, frame cards, tables, responsive layout.
  • script.js – All algorithms, simulation logic, Chart.js integration, UI controllers.
  • README.md – This documentation.

No build tools, no frameworks – just open index.html in any modern browser.

Algorithms Implemented

Algorithm Description
FIFO First-In-First-Out: Evicts the page that was loaded earliest.
LRU Least Recently Used: Evicts the page that has not been used for the longest period of time.
Optimal Optimal: Evicts the page that will not be used for the longest period of time in the future.
LFU Least Frequently Used: Evicts the page with the smallest reference count (used the least often).
MFU Most Frequently Used: Evicts the page with the highest reference count (used the most often).

Validation & Error Handling

  • Empty or malformed reference strings trigger user-friendly error toasts.
  • Frames must be >= 1 (and reasonably low for performance, max 20 enforced).
  • Invalid characters are caught and reported.

Development

No dependencies beyond Chart.js (loaded via CDN). To modify:

  • Edit style.css for visual changes.
  • Extend script.js with new algorithms (add a function and update the switch in runAlgorithm).
  • Update index.html to add more controls if needed.

Credits

Original concept from Disk Scheduling Algorithm Graph Plotter by Bitttu4.
This version transforms the same visual paradigm into a Page Replacement Visualizer for Operating Systems education.

License

MIT – free for educational and personal use.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages