# kondim23/mmu-page-replacement-simulator architecture

> Architecture diagram of the GitHub repository kondim23/mmu-page-replacement-simulator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kondim23/mmu-page-replacement-simulator
- Repository: https://github.com/kondim23/mmu-page-replacement-simulator

## Overview

This C simulator takes two memory-reference traces, alternates processing batches for two processes, translates virtual page references into frame-based physical addresses, and reports paging and disk-I/O statistics. Its main loop coordinates page lookup, page-fault handling, replacement, dirty-page accounting, and trace output. The internal layers are a hashed page table and frame-management code implementing LRU and Second Chance. The README documents these capabilities; the graph omits unsupported links beyond those shown in the excerpts.

Main entry points: [`src/simulator.c`](https://github.com/kondim23/mmu-page-replacement-simulator/blob/master/src/simulator.c) (Trace simulator), [`src/pageTable.c`](https://github.com/kondim23/mmu-page-replacement-simulator/blob/master/src/pageTable.c) (Page hash tables), [`src/memoryStructure.c`](https://github.com/kondim23/mmu-page-replacement-simulator/blob/master/src/memoryStructure.c) (Frame manager), [`data/bzip.trace`](https://github.com/kondim23/mmu-page-replacement-simulator/blob/master/data/bzip.trace) (Bzip trace)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sim["Simulation"]
  node_simulator["Trace simulator<br/>[simulator.c]"]
  node_bzip["Bzip trace<br/>[bzip.trace]"]
  node_gcc["GCC trace<br/>[gcc.trace]"]
end

subgraph group_memory["Memory Management"]
  node_pagehash["Page hash tables<br/>[pageTable.c]"]
  node_frames["Frame manager<br/>[memoryStructure.c]"]
  node_lru["LRU replacement<br/>[memoryStructure.c]"]
  node_secondchance["Second Chance<br/>[memoryStructure.c]"]
end

subgraph group_stats["Accounting"]
  node_statistics["Paging statistics<br/>[simulator.c]"]
end

node_user(("Simulator user"))

node_user -->|"selects options"| node_simulator
node_simulator -->|"reads references"| node_bzip
node_simulator -->|"reads references"| node_gcc
node_simulator -->|"searches pages"| node_pagehash
node_simulator -->|"updates mappings"| node_pagehash
node_simulator -->|"updates dirty bits"| node_frames
node_simulator -->|"dispatches replacement"| node_lru
node_simulator -->|"dispatches replacement"| node_secondchance
node_lru -->|"reads usage counters"| node_pagehash
node_secondchance -->|"reads reference bits"| node_pagehash
node_frames -->|"refreshes reference bits"| node_pagehash
node_simulator -->|"reports counts"| node_statistics
node_frames -->|"counts dirty frames"| node_statistics
node_simulator -->|"prints addresses"| node_user

click node_simulator "https://github.com/kondim23/mmu-page-replacement-simulator/blob/master/src/simulator.c"
click node_bzip "https://github.com/kondim23/mmu-page-replacement-simulator/blob/master/data/bzip.trace"
click node_gcc "https://github.com/kondim23/mmu-page-replacement-simulator/blob/master/data/gcc.trace"
click node_pagehash "https://github.com/kondim23/mmu-page-replacement-simulator/blob/master/src/pageTable.c"
click node_frames "https://github.com/kondim23/mmu-page-replacement-simulator/blob/master/src/memoryStructure.c"
click node_lru "https://github.com/kondim23/mmu-page-replacement-simulator/blob/master/src/memoryStructure.c"
click node_secondchance "https://github.com/kondim23/mmu-page-replacement-simulator/blob/master/src/memoryStructure.c"
click node_statistics "https://github.com/kondim23/mmu-page-replacement-simulator/blob/master/src/simulator.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_simulator,node_bzip,node_gcc,node_user toneBlue
class node_pagehash,node_frames,node_lru,node_secondchance toneAmber
class node_statistics toneMint
```

## Components

### Simulation

- [Trace simulator](https://github.com/kondim23/mmu-page-replacement-simulator/blob/master/src/simulator.c): `src/simulator.c`
- [Bzip trace](https://github.com/kondim23/mmu-page-replacement-simulator/blob/master/data/bzip.trace): `data/bzip.trace`
- [GCC trace](https://github.com/kondim23/mmu-page-replacement-simulator/blob/master/data/gcc.trace): `data/gcc.trace`

### Memory Management

- [Page hash tables](https://github.com/kondim23/mmu-page-replacement-simulator/blob/master/src/pageTable.c): `src/pageTable.c`
- [Frame manager](https://github.com/kondim23/mmu-page-replacement-simulator/blob/master/src/memoryStructure.c): `src/memoryStructure.c`
- [LRU replacement](https://github.com/kondim23/mmu-page-replacement-simulator/blob/master/src/memoryStructure.c): `src/memoryStructure.c`
- [Second Chance](https://github.com/kondim23/mmu-page-replacement-simulator/blob/master/src/memoryStructure.c): `src/memoryStructure.c`

### Accounting

- [Paging statistics](https://github.com/kondim23/mmu-page-replacement-simulator/blob/master/src/simulator.c): `src/simulator.c`

### Other components

- **Simulator user**

## Connections

- Simulator user → Trace simulator: selects options (evidence: `README.md`)
- Trace simulator → Bzip trace: reads references (evidence: `src/simulator.c`)
- Trace simulator → GCC trace: reads references (evidence: `src/simulator.c`)
- Trace simulator → Page hash tables: searches pages (evidence: `src/simulator.c`)
- Trace simulator → Page hash tables: updates mappings (evidence: `src/simulator.c`)
- Trace simulator → Frame manager: updates dirty bits (evidence: `src/simulator.c`)
- Trace simulator → LRU replacement: dispatches replacement (evidence: `src/simulator.c`)
- Trace simulator → Second Chance: dispatches replacement (evidence: `src/simulator.c`)
- LRU replacement → Page hash tables: reads usage counters (evidence: `src/memoryStructure.c`)
- Second Chance → Page hash tables: reads reference bits (evidence: `src/memoryStructure.c`)
- Frame manager → Page hash tables: refreshes reference bits (evidence: `src/memoryStructure.c`)
- Trace simulator → Paging statistics: reports counts (evidence: `src/simulator.c`)
- Frame manager → Paging statistics: counts dirty frames (evidence: `src/simulator.c`)
- Trace simulator → Simulator user: prints addresses (evidence: `src/simulator.c`)
