Thanks to visit codestin.com
Credit goes to github.com

Skip to content
/ PULSE Public

This project is a lightweight, deterministic C simulator for classic CPU scheduling, featuring a pluggable selector callback to model both preemptive and non-preemptive policies.

r-siddiq/PULSE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PULSE — Process Scheduling Simulator (C)

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.

Features

  • 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.

Project Layout

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

Build Requirements

  • GCC or Clang
  • make
  • [pkg-config]
  • [Criterion] test framework

Linux / WSL (Ubuntu/Debian)

sudo apt update
sudo apt install -y build-essential pkg-config libcriterion-dev
make            # builds test binary
make test       # runs the Criterion suite

macOS

# Xcode CLI tools (compilers)
xcode-select --install
# Criterion via Homebrew
brew install criterion pkg-config
make
make test

Docker (optional)

docker 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
'

Usage

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_PARAMSpreemptable, time_quantum, process_selection_func.
  • SCHEDULER_STATS — counters and aggregates; finalized by finalize_stats.

Implemented selectors (examples)

  • 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:

  1. Selects eligible processes at the current time.
  2. Chooses the next process with process_selection_func.
  3. Starts/stops processes, accrues statistics, and advances the clock.
  4. Continues until all processes complete or a guard time is reached.

Development

  • Code lives under src/; unit tests live under tests/ and unit_tests.c.
  • The provided Makefile uses pkg-config for 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

About

This project is a lightweight, deterministic C simulator for classic CPU scheduling, featuring a pluggable selector callback to model both preemptive and non-preemptive policies.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published