EfficientPageReplacementSimulator
A C++ & Python implementation of FIFO, LRU, and Optimal page replacement algorithms along with visualization.
Install / Use
/learn @hariteja-01/EfficientPageReplacementSimulatorREADME
Efficient Page Replacement Algorithm Simulator
📌 About the Project
This project implements three page replacement algorithms:
- FIFO (First In First Out)
- LRU (Least Recently Used)
- Optimal Page Replacement
It helps users understand how different memory management techniques perform by computing total page faults.
⚙️ Features
✅ Implements FIFO, LRU, and Optimal algorithms
✅ Accepts user input for frames and page references
✅ Calculates total page faults for each algorithm
✅ Generates visualization using Python Matplotlib
✅ Easy-to-understand C++ implementation
✅ Well-structured GitHub commits for version control
🔧 How to Run the Code
1️⃣ Clone the Repository
To get started, clone this repository using:
git clone https://github.com/hariteja-01/EfficientPageReplacementSimulator.git
cd EfficientPageReplacementSimulator
2️⃣ Compile the C++ Program
Ensure you have g++ installed (Windows users need MinGW). To compile the program, run:
g++ page_replacement.cpp -o simulator
3️⃣ Run the C++ Program
Execute the compiled file:
./simulator # For Linux/macOS
simulator.exe # For Windows
4️⃣ Install Python Dependencies
To generate the bar chart visualization, install Matplotlib:
pip install matplotlib
pip install tkinter
pip install numpy
5️⃣ Run the Python Visualization Script
Execute the Python script to generate a bar chart comparing the algorithms:
python3 visualize.py # For Linux/macOS
python visualize.py # For Windows
6️⃣ Source Code Files
Click on the file names to view the respective code:
- 📄 C++ Code → C++ implementation of FIFO, LRU, and Optimal page replacement algorithms.
- 📄 Python Code → Python script for visualization using Matplotlib.
- 📄 Text File → Auto-generated file containing the number of page faults after running the C++ program.
Flow Chart
<img src="https://github.com/hariteja-01/EfficientPageReplacementSimulator/blob/main/_-%20visual%20selection.png" alt="flowchart" width="500"/>📊 Example Visualization Output
After running the Python script, you will see a bar chart like this:
📊 Page Replacement Algorithm Comparison
- 🔴 FIFO: no. of page faults
- 🔵 LRU: no. of page faults
- 🟢 Optimal: no. of page faults
📌 This graph helps visualize which algorithm is more efficient based on page faults.
<img src="https://github.com/hariteja-01/EfficientPageReplacementSimulator/blob/main/_-%20visual%20selection%20(1).png" alt="flowchart" width="500"/>VS Code Screenshots
FIFO
<img src="https://github.com/hariteja-01/EfficientPageReplacementSimulator/blob/main/Project%20Screenshots/osproject1.jpg" alt="flowchart" width="500"/>LRU
<img src="https://github.com/hariteja-01/EfficientPageReplacementSimulator/blob/main/Project%20Screenshots/osproject2.jpg" alt="flowchart" width="500"/>Optimal
<img src="https://github.com/hariteja-01/EfficientPageReplacementSimulator/blob/main/Project%20Screenshots/osproject3.jpg" alt="flowchart" width="500"/>📜 License
This project is licensed under the MIT License - see the LICENSE file for details.
🚀 Authors
👤 Hari Teja Patnala
👤 Samad
👤 Dipesh Prabhakar
