A high-performance, interactive web application for visualizing and analyzing page replacement algorithms in operating systems. Built for students, educators, and systems programmers who need to understand memory management concepts through hands-on simulation.
- Overview
- Features
- Supported Algorithms
- Getting Started
- Usage
- Architecture
- Configuration Options
- Development
- Tech Stack
- License
PRsim provides a comprehensive simulation environment for page replacement algorithms, a fundamental concept in operating systems virtual memory management. The application enables real-time visualization of how different algorithms handle page faults, manage memory frames, and make replacement decisions.
Unlike static educational materials, PRsim allows users to observe algorithm behavior dynamically, compare performance metrics across all algorithms simultaneously, and export detailed simulation reports.
- Step-by-step execution with detailed state visualization
- Auto-play mode with configurable playback speed
- Real-time hit/fault counter and statistics
- Visual memory frame representation with animated transitions
- Contextual explanations for each algorithm decision
- Side-by-side performance comparison across all seven algorithms
- Interactive bar charts displaying page faults vs. hits
- Automatic identification of optimal algorithm for given input
- Hit rate percentage calculations with visual progress indicators
- Interactive game mode for testing algorithm comprehension
- Score tracking with accuracy metrics
- Immediate feedback on prediction correctness
- PDF report generation with dark-themed styling
- Complete simulation history including frame states
- Performance summary and algorithm comparison data
| Algorithm | Description |
|---|---|
| FIFO | First-In-First-Out. Replaces the oldest page in memory. Simple circular queue implementation. |
| LRU | Least Recently Used. Replaces the page that has not been accessed for the longest time. Tracks access recency via timestamps. |
| Optimal | Replaces the page that will not be used for the longest time in the future. Theoretical best-case with FIFO tie-breaking for pages never used again. |
| MFU | Most Frequently Used. Replaces the page with the highest access frequency. Supports configurable tie-breaking (FIFO/LIFO). |
| LFU | Least Frequently Used. Replaces the page with the lowest access frequency. Supports counter reset and tie-breaking strategies. |
| MRU | Most Recently Used. Replaces the most recently accessed page. Useful for specific access patterns. |
| Clock | Second Chance algorithm. Uses reference bits to give pages a second chance before replacement. Circular buffer with pointer-based traversal. |
- Node.js 18.0+
- npm 9.0+ or yarn
git clone <repository-url>
cd pr-sim
npm install# Development server with hot reload
npm run dev
# Production build
npm run build
# Preview production build
npm run previewThe development server starts at http://localhost:5173 by default.
-
Enter a reference string (space-separated page numbers):
7 0 1 2 0 3 0 4 2 3 0 3 2 -
Configure the number of memory frames (1-10)
-
Select a page replacement algorithm
-
Click Start Simulation
-
Navigate through steps using:
- Next/Previous buttons for manual control
- Auto-play for continuous execution
- Reset to restart the simulation
- Green indicators: Page hits (page already in memory)
- Red indicators: Page faults (page not in memory, requires loading)
- Frame visualization: Current state of memory with page assignments
- Explanation panel: Step-by-step reasoning for each operation
Upon simulation completion, the comparison chart displays:
- Total page faults per algorithm
- Total hits per algorithm
- Best-performing algorithm highlighted
src/
├── algorithms/ # Algorithm implementations
│ ├── fifo.js # FIFO page replacement
│ ├── lru.js # LRU page replacement
│ ├── optimal.js # Optimal page replacement
│ ├── mfu.js # MFU page replacement
│ ├── lfu.js # LFU page replacement
│ ├── mru.js # MRU page replacement
│ └── clock.js # Clock/Second Chance
├── components/ # React UI components
│ ├── LandingPage.jsx # Landing page with documentation
│ ├── InputPanel.jsx # Configuration form
│ ├── SimulationGrid.jsx # Memory frame visualization
│ ├── ControlPanel.jsx # Playback controls
│ ├── ChartView.jsx # Algorithm comparison charts
│ ├── ExplanationBox.jsx # Step explanations
│ ├── Results.jsx # Simulation results
│ └── GameMode.jsx # Interactive learning mode
├── utils/
│ └── pdfGenerator.js # PDF export functionality
├── App.jsx # Application root
├── main.jsx # Entry point
└── index.css # Global styles
Each algorithm exports a function with the following signature:
function algorithm(referenceString, numFrames, options?) {
return {
history: Array<StepRecord>,
totalPageFaults: number,
hitRate: string
}
}| Option | Type | Default | Description |
|---|---|---|---|
resetCounter |
boolean | false | Reset frequency count when a page is removed |
tieBreaking |
'FIFO' | 'LIFO' | 'FIFO' | Strategy for breaking ties when pages have equal frequency |
npm run dev # Start development server
npm run build # Create production build
npm run preview # Preview production build locally
npm run lint # Run ESLintThe project uses ESLint with React-specific rules. Run linting before commits:
npm run lint| Category | Technology |
|---|---|
| Framework | React 19 |
| Build Tool | Vite 7 |
| Styling | Tailwind CSS 3 |
| Animations | Framer Motion |
| Charts | Recharts |
| PDF Generation | jsPDF |
| Smooth Scrolling | Lenis |
| Icons | Lucide React |
MIT License. See LICENSE for details.
Author: Muhammad Ahmad