Chronos logo

Rust · clap only · no fabricated numbers

Gantt charts, run for real,
not sketched on a whiteboard.

Chronos is a CPU scheduler in Rust. It simulates FIFO, SJF, round-robin, priority, and MLFQ over a set of processes and reports the actual completion, turnaround, waiting, and response times. Here is the real algorithm, running in your browser.

PIDArrivalBurstPriority
PIDArrivalBurstCompletionTurnaroundWaitingResponse
How to use this playground

Chronos runs CPU scheduling algorithms for real: choose an algorithm, describe some processes, and watch the Gantt chart and metrics update instantly.

  • Pick an Algorithm. For round robin and MLFQ, set the Quantum (the time slice).
  • Edit the process table: each row is an arrival time and a burst length, plus a priority for the priority scheduler. Use + Add process or Reset sample.
  • Read the Gantt chart to see the exact run order, then the table for per-process completion, turnaround, waiting, and response times, with the averages below.

How each scheduler decides.

The same five algorithms the Rust binary runs, ported line for line into the demo above.

1

FIFO

Sorted by arrival time, ties by id. Runs each process to completion in that order, no interruption.

2

SJF

Non-preemptive. Among processes that have arrived, always picks the smallest remaining burst next.

3

Round robin

Every ready process gets a fixed quantum, cycling through the queue until each one finishes.

4

Priority

Non-preemptive. Picks the lowest priority value among arrived processes, lower value runs first.

5

MLFQ

Three levels, quantum 4 then 8 then FCFS. A process that burns its whole quantum gets demoted a level.

6

Metrics

Completion, turnaround, waiting, and response are computed from the real timeline, then averaged.

The same run, on the terminal.

The binary prints the Gantt chart as a labeled block sequence with time marks underneath, then the per-process metrics and the averages. This is real output captured from the CLI.

# round robin, quantum 2, three processes $ chronos run --algo rr --quantum 2 --procs "0:5,1:3,2:8" |P0 |P1 |P2 |P0 |P1 |P2 |P0 |P2 | 0 2 4 6 8 9 11 12 16 PID Arrival Burst Completion Turnaround Waiting Response 0 0 5 12 12 7 0 1 1 3 9 8 5 1 2 2 8 16 14 6 2 Averages: turnaround=11.33 waiting=6.00 response=1.00

What makes it different.

Chronos is built to be trusted as a reference, not just to draw a chart. The design choices below are the reason.

Real timelines, not rounded textbook numbers

Completion, turnaround, waiting, and response are computed from the actual simulated timeline of every scheduler, then averaged. Nothing is hand-fudged.

Deterministic and pure

Every scheduler is a pure function of its input. The same processes always produce the same Gantt chart and metrics, which is what makes the tests meaningful.

No workload panics it

Processes that all arrive at the same instant, idle gaps between arrivals, and a single-process workload are all handled without crashing.

Tested against hand-computed answers

The suite asserts exact metrics for every algorithm, including a traced round-robin run and an MLFQ run that demotes a long job across all three levels.

Run it from the command line.

One subcommand, five algorithms, described entirely on the command line.

# round robin, quantum 2, three processes
cargo run -- run --algo rr --quantum 2 --procs "0:5,1:3,2:8"

# or pick any of the five algorithms
cargo run -- run --algo fifo --procs "0:5,1:3,2:8"
cargo run -- run --algo sjf --procs "0:8,1:3,2:4"
cargo run -- run --algo priority --procs "0:5:2,1:3:1,2:8:0"
cargo run -- run --algo mlfq --quantum 4 --procs "0:20,1:2"

Three ways in.

CLI

The run subcommand takes --algo (fifo, sjf, rr, priority, mlfq), an optional --quantum, and --procs as a comma-separated list of arrival:burst or arrival:burst:priority entries. Built with clap and nothing else.

Library

The schedulers ship as a Rust library crate (chronos, src/lib.rs), so the scheduling functions and metric computation are callable directly from your own code.

Tests

Run cargo test to drive every scheduler against exact, hand-computed metrics, including traced round-robin and multi-level MLFQ demotion cases.