A comprehensive Operating Systems project that simulates and analyzes multiple page replacement algorithms to understand how modern operating systems manage memory under limited physical resources.
Modern operating systems rely on virtual memory to efficiently manage limited physical RAM. Processes generate memory access requests in the form of page references, and when a requested page is not present in memory, a page fault occurs.
When memory frames are full, the operating system must decide which page to evict. This decision is governed by a page replacement algorithm.
This project implements a Page Replacement Algorithm Analyzer that simulates this behavior and compares different page replacement strategies based on their performance, measured using page fault counts and graphical analysis.
- Simulate real-world page replacement behavior
- Implement and compare multiple replacement algorithms
- Analyze algorithm performance using page fault statistics
- Visualize results using meaningful graphs
- Strengthen conceptual understanding of memory management in operating systems
The following page replacement algorithms are implemented and analyzed:
-
FIFO (First In First Out)
Replaces the page that has been in memory the longest. -
LRU (Least Recently Used)
Replaces the page that has not been used for the longest time. -
Optimal (OPT)
Replaces the page that will not be used for the longest time in the future (theoretical benchmark). -
LFU (Least Frequently Used)
Replaces the page with the lowest access frequency. -
Second Chance (Clock Algorithm)
An improved FIFO variant using reference bits. -
Random Replacement
Replaces a randomly selected page (baseline comparison).
- The user enters a page reference string
- The user specifies the number of memory frames
- Memory is initialized as empty frames
- Each page request is processed sequentially
- Page hits and page faults are detected
- Replacement decisions are made based on the selected algorithm
- Page faults are counted and tracked
- Results are displayed step-by-step
- Graphs are generated for performance comparison
This bar chart compares total page faults generated by each algorithm.
Shows how page faults accumulate as page references are processed.
Demonstrates how increasing memory frames affects algorithm performance.
- Python 3
- Matplotlib (for graph generation)
- Python standard libraries (
collections,random,typing)
- Clone the repository
git clone https://github.com/your-username/page-replacement-algorithm-analyzer.git- Navigate to the project directory
cd page-replacement-algorithm-analyzer- 3️ Install dependencies
pip install -r requirements.txt- 4️ Run the analyzer
python src/page_replacement_analyzer.pyEnter page reference string (space-separated):
7 0 1 2 0 3 0 4 2 3 0 3 2
Enter number of frames:
3page-replacement-algorithm-analyzer/
│
├── src/ # Core simulation code
├── assets/ # Images and generated graphs
├── diagrams/ # Flowcharts and diagrams
├── report/ # Academic report (PDF)
├── README.md
└── requirements.txt
This project is intended for educational and academic purposes only.


