A comprehensive C-based simulator for virtual memory management systems featuring multiple page replacement algorithms, TLB simulation, and working set analysis.
- FIFO (First In, First Out) - Simple queue-based replacement
- LRU (Least Recently Used) - Optimal for temporal locality
- Optimal Algorithm - Theoretical best performance benchmark
- Clock Algorithm - Efficient approximation of LRU with dirty bit support
-
TLB (Translation Lookaside Buffer) Simulation
- Configurable hit/miss ratios
- Address translation performance tracking
- Memory access time calculations
-
Working Set Analysis
- Locality pattern detection
- Frame allocation optimization
- Memory utilization metrics
-
Belady's Anomaly Detection
- Automated test case generation
- Statistical analysis of anomaly occurrences
- Performance comparison across frame sizes
=== Virtual Memory Simulation Results ===
Algorithm: LRU
Frames: 4
Sequence Length: 20
Page Faults: 15
Hit Ratio: 25.00%
Miss Ratio: 75.00%
=== TLB Statistics ===
TLB Hits: 16
TLB Misses: 4
TLB Hit Ratio: 80.00%
Average Access Time: 1.4 ns
=== Working Set Analysis ===
Average Working Set Size: 3.2
Locality Score: 0.65
Recommended Frames: 4
- Simple queue-based replacement
- O(1) replacement decision
- Susceptible to Belady's anomaly
- Uses timestamp-based tracking
- Optimal for temporal locality
- O(n) time complexity for updates
- Looks ahead in reference string
- Theoretical minimum page faults
- Used as performance benchmark
- Circular list with reference bits
- Dirty bit support for write-back
- Efficient approximation of LRU
The simulator performs working set analysis to:
- Detect memory access patterns
- Identify locality of reference
- Recommend optimal frame allocation
- Track memory utilization over time
Automated detection system that:
- Generates test cases across different frame sizes
- Identifies cases where more frames result in more page faults
- Provides statistical analysis of anomaly frequency
1 2 3 4 1 2 5 1 2 3 4 5
7 0 1 2 0 3 0 4 2 3 0 3 2
1 2 3 4 5 6 7 8 9 10 11 12