PULSE is a lightweight, deterministic C simulator for classic CPU scheduling. Centered on a single event driven scheduling loop and a pluggable selector callback, it models both preemptive and non-preemptive policies and produces reproducible metrics (completion time, turnaround, and response) per run. The codebase is built with a cross-platform Makefile, and backed by an extensive Criterion test suite (unit and end-to-end) that locks in behavior and makes adding new policies as simple as implementing one selector function.
- Schedulers: FIFO, LIFO, SJF (non‑preemptive), STCF (preemptive SJF), Static Priority, and Round‑Robin.
- Deterministic simulation loop with a pluggable process selection function pointer.
- Statistics tracking: completion time, per‑process response time, and turnaround time (with averages).
- Cross‑platform build with
make+ [Criterion] unit tests.
PULSE/
├─ Makefile
├─ README.md
├─ unit_tests.c # test runner entry
├─ src/
│ ├─ common.h
│ ├─ process.h / process.c
│ ├─ process_list.h / process_list.c
│ ├─ process_scheduling.h / process_scheduling.c
│ ├─ statistics.h / statistics.c
│ ├─ student_code.h / student_code.c # scheduler implementations
│ └─ tests.h / tests.c # shared test helpers
└─ tests/
├─ unittests_end2end.c
├─ unittests_fifo.c
├─ unittests_lifo.c
├─ unittests_priority.c
├─ unittests_rr.c
├─ unittests_sjf.c
├─ unittests_stcf.c
└─ unittests_helpers.c
- GCC or Clang
make- [pkg-config]
- [Criterion] test framework
sudo apt update
sudo apt install -y build-essential pkg-config libcriterion-dev
make # builds test binary
make test # runs the Criterion suite# Xcode CLI tools (compilers)
xcode-select --install
# Criterion via Homebrew
brew install criterion pkg-config
make
make testdocker run --rm -it -v "$PWD":/app -w /app gcc:latest bash -lc '
apt-get update && apt-get install -y build-essential pkg-config libcriterion-dev &&
make && make test
'This repository is organized as a library + tests. The entry point for tests is unit_tests.c. The scheduler is driven by a SCHEDULER_PARAMS struct that defines whether the policy is preemptive, the time quantum (for RR), and a function pointer that selects the next ready process.
Key types live in src/:
PROCESS— id,entry_time,duration,time_remaining,priority(lower value = higher priority).PROCESS_LIST— dynamic list with helpers to add/remove/filter ready and incomplete processes.SCHEDULER_PARAMS—preemptable,time_quantum,process_selection_func.SCHEDULER_STATS— counters and aggregates; finalized byfinalize_stats.
fifo_process_selector(PROCESS_LIST*)— earliest entry.lifo_process_selector(PROCESS_LIST*)— most recent entry (stable on ties).sjf_process_selector(PROCESS_LIST*)— shortest duration first (non‑preemptive).stcf_process_selector(PROCESS_LIST*)— shortest time‑remaining first (preemptive).priority_process_selector(PROCESS_LIST*)— lowest numeric priority first.rr_process_selector(PROCESS_LIST*)— round‑robin using an internal rotating index.
The simulation loop (process_scheduling_loop) repeatedly:
- Selects eligible processes at the current time.
- Chooses the next process with
process_selection_func. - Starts/stops processes, accrues statistics, and advances the clock.
- Continues until all processes complete or a guard time is reached.
- Code lives under
src/; unit tests live undertests/andunit_tests.c. - The provided
Makefileusespkg-configfor Criterion and works on Linux, macOS, and WSL. - Clean builds:
make clean. - Treat warnings as errors during development:
CFLAGS='-g -Wall -Wextra -Wpedantic -Werror' make