cpusched-ash-win-cpu — CPU Scheduling Simulator
cpusched-ash-win-cpu is a production-quality, zero-dependency Python library for simulating CPU scheduling algorithms. It is designed for operating-systems courses, research, and anyone who needs to compare scheduler behaviour quickly.
Features
| Algorithm | Type |
|---|---|
| FCFS | Non-preemptive |
| SJF | Non-preemptive |
| SRTF | Preemptive (shortest remaining time) |
| Priority | Non-preemptive |
| PriorityPreemptive | Preemptive |
| Round Robin | Preemptive (configurable quantum) |
| MLFQ | Preemptive (configurable levels + boost) |
| EEVDF | Preemptive (Linux 6.6+ default scheduler) |
Metrics computed:
- Waiting time, Turnaround time, Response time (per-process + averages)
- CPU utilization
- Throughput (processes per time unit)
Output formats:
- Text Gantt chart
- Self-contained HTML Gantt chart
- CSV export (process list, metrics, Gantt)
Installation
pip install cpusched-ash-win-cpu
Or install from source:
git clone https://github.com/example/cpusched-ash-win-cpu
cd cpusched-ash-win-cpu
pip install -e ".[dev]"
Quick Start
from cpusched import Process, Simulator
processes = [
Process("P1", arrival_time=0, burst_time=6, priority=2),
Process("P2", arrival_time=2, burst_time=8, priority=1),
Process("P3", arrival_time=4, burst_time=7, priority=3),
]
sim = Simulator(processes)
# Run a single algorithm
result = sim.run("fcfs")
print(result.summary())
# Compare all algorithms
all_results = sim.run_all(rr_quantum=4)
print(sim.compare(all_results))
Output
Algorithm : FCFS
------------------------------------------------------------
PID Arrival Burst Finish WT TAT RT
------------------------------------------------------------
P1 0 6 6 0 6 0
P2 2 8 14 4 12 4
P3 4 7 21 10 17 10
------------------------------------------------------------
Avg Waiting Time : 4.67
Avg Turnaround : 11.67
Avg Response Time : 4.67
CPU Utilization : 100.0%
Throughput : 0.1429 proc/unit
------------------------------------------------------------
Gantt Chart:
| P1 | P2 | P3 |
0 6 14 21
Usage by Algorithm
FCFS
from cpusched import FCFS, Process
result = FCFS([Process("P1", 0, 6), Process("P2", 2, 4)]).run()
SJF / SRTF
from cpusched import SJF, SRTF
result_sjf = SJF(processes).run()
result_srtf = SRTF(processes).run()
Priority (non-preemptive and preemptive)
from cpusched import Priority, PriorityPreemptive
result = Priority(processes).run() # non-preemptive
result = PriorityPreemptive(processes).run() # preemptive
Lower priority value = higher urgency.
Round Robin
from cpusched import RoundRobin
result = RoundRobin(processes, quantum=4).run()
MLFQ
from cpusched import MLFQ
result = MLFQ(
processes,
quantums=[8, 16, 32], # per-level time quanta
boost_interval=50, # 0 = no boost (starvation prevention disabled)
).run()
EEVDF (Linux 6.6+ default)
from cpusched import EEVDF
result = EEVDF(processes, quantum=8).run()
CSV Import / Export
from cpusched import load_processes_csv, save_result_csv, save_gantt_csv
# Load processes from a CSV file
processes = load_processes_csv("processes.csv")
# CSV format
# pid,arrival_time,burst_time,priority
# P1,0,6,2
# P2,2,8,1
# Export metrics
save_result_csv(result, "metrics.csv")
# Export Gantt entries
save_gantt_csv(result, "gantt.csv")
Gantt Chart Rendering
from cpusched import GanttRenderer
renderer = GanttRenderer(result)
# Text chart
print(renderer.text())
# Save HTML chart (self-contained, open in any browser)
renderer.save_html("gantt.html")
Command-Line Interface
# Built-in demo with 5 sample processes
cpusched demo
# Run FCFS on your own CSV
cpusched run --file procs.csv --algo fcfs
# Run all algorithms and compare
cpusched run --file procs.csv --all --quantum 4
# Export to HTML Gantt + CSV metrics
cpusched run --file procs.csv --algo rr --quantum 4 \
--html gantt.html --export metrics.csv
# Aliases accepted
cpusched run --file procs.csv --algo priority_preemptive
cpusched run --file procs.csv --algo round_robin --quantum 3
Running Tests
pip install -e ".[dev]"
pytest tests/ -v --cov=cpusched
Project Structure
cpusched/
├── cpusched/
│ ├── __init__.py # Public API
│ ├── __main__.py # CLI (python -m cpusched)
│ ├── process.py # Process, GanttEntry, SchedulingResult
│ ├── base.py # BaseScheduler, SchedulingResultBuilder
│ ├── simulator.py # Simulator facade
│ ├── gantt.py # text_gantt, html_gantt, GanttRenderer
│ ├── io.py # CSV import/export
│ └── algorithms/
│ ├── __init__.py
│ ├── classic.py # FCFS, SJF, SRTF, Priority, PriorityPreemptive
│ ├── rr_mlfq.py # RoundRobin, MLFQ
│ └── eevdf.py # EEVDF
├── tests/
│ └── test_cpusched.py # ~80 unit tests
├── pyproject.toml
└── README.md
License
MIT
Metadata
Release files for cpusched-ash-win-cpu 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cpusched_ash_win_cpu-1.0.1.tar.gz | 25.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cpusched_ash_win_cpu-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 48.4 kB
Release files / cpusched_ash_win_cpu-1.0.1.tar.gz
| Download URL | cpusched_ash_win_cpu-1.0.1.tar.gz |
|---|---|
| Size | 25.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dd31e8ec2bb18d16c58c9a30873e6d021b3fa027610e02f9c65daf6430985c7f
|
|
BLAKE2b-256 checksum How to use checksums |
86d18d1b239be8a78cbeba269d45de1ed92c86385804570b9ebceaded3e1929a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Release files / cpusched_ash_win_cpu-1.0.1-py3-none-any.whl
| Download URL | cpusched_ash_win_cpu-1.0.1-py3-none-any.whl |
|---|---|
| Size | 23.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
82e592a7dc85b8579f2d5e3f912a1aac188220f9f064fd7b48e24f479f3a61e2
|
|
BLAKE2b-256 checksum How to use checksums |
10e9aa90749c34584b2062890a7c095ce1db4bb9e4212f3e45b05efd19207867
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|