Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Virtual Memory Manager Simulator

A comprehensive C-based simulator for virtual memory management systems featuring multiple page replacement algorithms, TLB simulation, and working set analysis.

🚀 Features

Core Page Replacement Algorithms

  • 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

Advanced Features

  • 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

📊 Output and Analysis

Console Output

=== 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

📈 Algorithms Implemented

1. FIFO (First In, First Out)

  • Simple queue-based replacement
  • O(1) replacement decision
  • Susceptible to Belady's anomaly

2. LRU (Least Recently Used)

  • Uses timestamp-based tracking
  • Optimal for temporal locality
  • O(n) time complexity for updates

3. Optimal Algorithm

  • Looks ahead in reference string
  • Theoretical minimum page faults
  • Used as performance benchmark

4. Clock Algorithm

  • Circular list with reference bits
  • Dirty bit support for write-back
  • Efficient approximation of LRU

🔍 Working Set Analysis

The simulator performs working set analysis to:

  • Detect memory access patterns
  • Identify locality of reference
  • Recommend optimal frame allocation
  • Track memory utilization over time

⚠️ Belady's Anomaly Detection

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

📋 Sample Test Cases

Test Sequence 1 - High Locality

1 2 3 4 1 2 5 1 2 3 4 5

Test Sequence 2 - Random Access

7 0 1 2 0 3 0 4 2 3 0 3 2

Test Sequence 3 - Sequential Access

1 2 3 4 5 6 7 8 9 10 11 12

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages