Skip to content

Trace driven virtual memory page replacement simulator and synthetic workload scheduling simulator (C)

Notifications You must be signed in to change notification settings

GianCarp/os-simulators

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OS Simulators

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.

Project layout

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.

Components

memsim/ — Virtual Memory Simulator

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/ — CPU Scheduling Simulator

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.


tools/ — Supporting Utilities

The tools directory contains helper programs used to generate inputs for the simulators.

workload_gen

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.


Building the project

All components are built from the repository root using the top-level Makefile.

To build everything:

make

This produces the following binaries in build/:

build/memsim
build/schedsim
build/workload_gen

Individual components can also be built explicitly:

make memsim
make schedsim
make workload_gen

Workflow

A common workflow when exploring scheduling behaviour is:

  1. Generate a workload: ./build/workload_gen -n 20 > schedsim/workloads/example.txt
  2. Run the scheduler: ./build/schedsim schedsim/workloads/example.txt --all --time-slice 4
  3. Compare metrics across policies and reason about trade-offs.

Similarly, memsim can be run directly against real memory traces provided in memsim/traces/

Future work

Planned extensions include:

  • Multi-Level Feedback Queue (MLFQ) scheduling
  • Ticket-based scheduling (lottery / stride)
  • Multi-core scheduling support
  • Shared analysis tooling across simulators

About

Trace driven virtual memory page replacement simulator and synthetic workload scheduling simulator (C)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published