Memory Paging Simulator for Evaluating Page Replacement Algorithms
This project simulates how modern operating systems manage virtual memory paging using classic page replacement algorithms.
Implemented in C, the simulator models realistic process workloads, page referencing patterns, and evaluates algorithm efficiency across multiple runs.
Developed as part of Advanced Operating Systems (COEN 383) at Santa Clara University under the guidance of Prof. Ahmed Ezzat.
-
Simulates five major page replacement algorithms:
- FIFO (First-In-First-Out)
- LRU (Least Recently Used)
- LFU (Least Frequently Used)
- MFU (Most Frequently Used)
- Random Pick
-
Models locality of reference — 70% probability to access a nearby page, 30% for distant jumps.
-
Tracks hit ratio, miss ratio, and page swaps per algorithm.
-
Dynamically generates 150 random processes with randomized arrival times, sizes, and durations.
-
Prints detailed logs of page-in, page-out, and job swaps for each simulated run.
- Job – represents a simulated process with attributes such as name, size, arrival time, and service duration.
- Page – represents an individual memory page with reference history and ownership details.
- Memory – a dynamic structure managing page frames, allocation, and replacements.
| Function | Description |
|---|---|
generateWorkload() |
Generates 150 random jobs with varying process sizes (5, 11, 17, or 31 MB). |
runSimulation() |
Runs each page replacement algorithm, tracks hits/misses, and swaps. |
generateNextPageReference() |
Simulates page references using locality (70% near ±1, 30% jump). |
| Algorithm | Hit % | Miss % | Page Swaps |
|---|---|---|---|
| FIFO | 41% | 59% | 3177 |
| LRU | 46% | 54% | 3289 |
| LFU | 38% | 62% | 3423 |
| MFU | 33% | 67% | 3161 |
| Random | 37% | 63% | 3374 |
(Example chart comparing hit/miss ratios across algorithms for random pick algorithm.)
- LRU consistently achieved the highest hit ratio (46%), confirming its efficiency in preserving temporal locality.
- FIFO showed moderate results but suffers from Belady’s anomaly under certain workloads.
- LFU and Random Pick demonstrated weaker adaptability to dynamic access patterns.
- MFU performed the worst, with only 33% hit ratio, since evicting frequently used pages breaks locality.
This simulation highlights how the choice of page replacement strategy directly affects system performance.
Among all tested algorithms, LRU emerges as the most balanced and effective approach for minimizing page faults in workloads that exhibit locality.
# Compile
make
# Run
./page_replacement_simulator
