Metadata-Version: 2.4
Name: cpusched-ash-win-cpu
Version: 1.0.1
Summary: Production-quality CPU scheduling simulator: FCFS, SJF, SRTF, Priority, Round Robin, MLFQ, EEVDF
Author: cpusched contributors
License: MIT
Project-URL: Homepage, https://github.com/example/cpusched-ash-win-cpu
Project-URL: Documentation, https://github.com/example/cpusched-ash-win-cpu#readme
Project-URL: Repository, https://github.com/example/cpusched-ash-win-cpu
Project-URL: Issues, https://github.com/example/cpusched-ash-win-cpu/issues
Keywords: cpu scheduling,operating systems,fcfs,sjf,srtf,round robin,mlfq,eevdf,gantt chart,simulation
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Education
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: System :: Operating System
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"
Requires-Dist: ruff>=0.4; extra == "dev"

# cpusched-ash-win-cpu — CPU Scheduling Simulator

[![PyPI](https://img.shields.io/pypi/v/cpusched-ash-win-cpu)](https://pypi.org/project/cpusched-ash-win-cpu/)
[![Python 3.9+](https://img.shields.io/badge/python-3.9%2B-blue)](https://www.python.org/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow)](LICENSE)

**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

```bash
pip install cpusched-ash-win-cpu
```

Or install from source:

```bash
git clone https://github.com/example/cpusched-ash-win-cpu
cd cpusched-ash-win-cpu
pip install -e ".[dev]"
```

---

## Quick Start

```python
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

```python
from cpusched import FCFS, Process

result = FCFS([Process("P1", 0, 6), Process("P2", 2, 4)]).run()
```

### SJF / SRTF

```python
from cpusched import SJF, SRTF

result_sjf  = SJF(processes).run()
result_srtf = SRTF(processes).run()
```

### Priority (non-preemptive and preemptive)

```python
from cpusched import Priority, PriorityPreemptive

result = Priority(processes).run()            # non-preemptive
result = PriorityPreemptive(processes).run()  # preemptive
```

Lower `priority` value = higher urgency.

### Round Robin

```python
from cpusched import RoundRobin

result = RoundRobin(processes, quantum=4).run()
```

### MLFQ

```python
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)

```python
from cpusched import EEVDF

result = EEVDF(processes, quantum=8).run()
```

---

## CSV Import / Export

```python
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

```python
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

```bash
# 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

```bash
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
