This repository contains a collection of small, focused simulators for exploring core operating system policies in controlled environments. Each simulator isolates a specific OS mechanism (e.g. CPU scheduling, virtual memory replacement) and exposes its behaviour through reproducible workloads and detailed metrics.
The goal of the project is not to emulate a full operating system, but to make individual policy decisions explicit, observable, and comparable, while keeping implementations simple enough to reason about and extend.
os-simulators/
├── memsim/ # Virtual memory page replacement simulator
├── schedsim/ # Single-core CPU scheduling simulator
├── tools/ # Supporting tools (e.g. workload generators)
├── build/ # Build outputs (ignored by git)
├── makefile # Top-level build orchestration
└── README.md # This file
Each subdirectory contains its own README with detailed design notes and usage instructions.
memsim simulates page replacement policies using real memory traces. It is
designed to explore how different page replacement strategies behave under realistic
access patterns.
Supported policies include:
- FIFO
- LRU
- CLOCK
- CLEAN-CLOCK
- Random
The simulator reports page fault rates, disk reads, and disk writes, and supports deterministic replay via a fixed RNG seed.
See memsim/README.md for full details.
schedsim is a single-core CPU scheduling simulator used to compare the
behaviour of different scheduling policies under controlled workloads.
Currently supported policies:
- First Come First Served (FCFS)
- Shortest Job First (SJF)
- Round Robin (RR)
For a given invocation of the program, each policy is run against the same immutable workload, and the simulator reports standard scheduling metrics such as response time, turnaround time, waiting time, and makespan.
The implementation focuses on:
- explicit policy boundaries
- private per-policy state
- clear, explainable scheduling decisions
See schedsim/README.md for architecture, metrics, and
policy details.
The tools directory contains helper programs used to generate inputs for the
simulators.
A command-line workload generator for schedsim that produces synthetic job
arrival patterns and run-time distributions.
Features:
- deterministic output via fixed seeds
- uniform and bursty arrival patterns
- configurable arrival windows and run-time ranges
- Unix-style output via stdout (supports piping and inspection)
See tools/README.md for usage and implementation notes.
All components are built from the repository root using the top-level Makefile.
To build everything:
makeThis produces the following binaries in build/:
build/memsim
build/schedsim
build/workload_genIndividual components can also be built explicitly:
make memsim
make schedsim
make workload_genA common workflow when exploring scheduling behaviour is:
- Generate a workload:
./build/workload_gen -n 20 > schedsim/workloads/example.txt - Run the scheduler:
./build/schedsim schedsim/workloads/example.txt --all --time-slice 4 - Compare metrics across policies and reason about trade-offs.
Similarly, memsim can be run directly against real memory traces provided in memsim/traces/
Planned extensions include:
- Multi-Level Feedback Queue (MLFQ) scheduling
- Ticket-based scheduling (lottery / stride)
- Multi-core scheduling support
- Shared analysis tooling across simulators