MegatronixOS is an educational operating systems project developed in C that simulates the behavior of a direct-mapped CPU cache memory system. The simulator processes memory access requests, detects cache hits and misses, loads memory blocks from RAM when required, and generates detailed execution statistics such as cache faults, average access time and reconstructed output data.
The project was designed to explore low-level systems programming concepts, including memory hierarchy management, cache organization, address decoding and binary file manipulation. By emulating the interaction between the CPU, cache and RAM, it provides a practical understanding of how modern computer architectures optimize memory access performance.
MegatronixOS/
├── MEMsym.c
├── CONTENTS_RAM.bin
└── accesos_memoria.txt
MEMsym.c: main source code of the cache memory simulator.CONTENTS_RAM.bin: binary file representing the simulated RAM (input).accesos_memoria.txt: input file containing memory addresses requested by the CPU.
CONTENTS_CACHE.bin and logcache.txt are generated when you run the simulator (see Output Files) and aren't tracked in this repository (see .gitignore) — they get overwritten on every run, so keeping old copies in git would just go stale. Want to see what they look like without compiling anything? Check the demo branch for an example of both.
- The simulator loads the RAM contents from
CONTENTS_RAM.bin. - Memory addresses are read sequentially from
accesos_memoria.txt. - Each address is decoded into tag, line, word and block fields.
- The cache determines whether the access is a HIT or a MISS.
- On a MISS, the corresponding memory block is loaded from RAM into the cache.
- The simulator continuously updates cache statistics and execution time.
- Detailed execution information is recorded in
logcache.txt, including cache hits, cache misses, memory block loads and cache state snapshots. - The final cache state is exported to
CONTENTS_CACHE.bin. - A summary report containing total accesses, cache misses, average access time and reconstructed output text is displayed at the end of execution.
After execution, the simulator generates the following outputs:
CONTENTS_CACHE.bin: binary dump containing the final state of the cache memory.logcache.txt: detailed execution report showing cache activity throughout the simulation.
The terminal output also displays:
- Total memory accesses
- Cache misses
- Average access time
- Reconstructed text obtained from memory accesses
- C
- GNU GCC
- Linux
- POSIX APIs
Clone the repository:
git clone https://github.com/chiissuu/MegatronixOS.git
cd MegatronixOSCompile the project:
gcc MEMsym.c -o megatronixosRun the executable:
./megatronixosContributions, bug reports and feature suggestions are welcome.
- Fork the repository
- Create a feature branch
- Commit your changes
- Open a Pull Request
- Jesús León Romero Atienza (Username de GITHUB: chiissuu)
- Mario Viso Quito (Username de GITHUB: Marioo239)
MIT — © 2026 Jesús León Romero Atienza, Mario Viso Quito.