A C++ simulation of a virtual memory system using paging and the Least Recently Used (LRU) page replacement algorithm. It handles address translation, page faults, memory allocation, and displays performance stats after simulated memory accesses.
This project models how an operating system manages virtual memory using a paging mechanism. It simulates virtual-to-physical address translation, detects page faults, allocates physical frames, and replaces pages using the LRU algorithm.
Key components include:
- Page Table Management
- Frame Table Tracking
- Random Memory Access Simulation
- Page Replacement Handling (LRU)
- Console Reporting of Memory Stats
| Configuration | Value |
|---|---|
| Page Size | 4096 bytes |
| Physical Memory | 65536 bytes (64 KB) |
| Virtual Memory | 131072 bytes (128 KB) |
| Physical Frames | 16 |
| Virtual Pages | 32 |
- β Virtual to Physical Address Translation
β οΈ Page Fault Handling- π LRU Page Replacement Strategy
- π Referenced & Modified Bit Management
- π Page and Frame Table Display
- π§ͺ 20 Random Memory Accesses (Read/Write)
- π Performance Statistics (Fault Rate, Usage)
g++ -std=c++11 paging_simulator.cpp -o paging_simulator
βΆοΈ Run:
bash
Copy
Edit
./paging_simulator
π₯οΈ Output Example
Virtual & Physical Address Mapping
Page Fault Messages
Frame Allocation Logs
Page Replacements with LRU Info
Final Page Table & Frame Table Display
Page Fault Rate Summary
π Educational Use
This simulator is perfect for:
Operating Systems coursework
Visualizing memory management
Learning about paging & LRU in C++
π License
Licensed under the MIT License.
π€ Contributing
Contributions are welcome! Please open an issue or submit a pull request for improvements or feature ideas.
π¬ Contact
For issues, suggestions, or questions, feel free to open an issue on the GitHub repository.