# ๐Ÿ–ฅ๏ธ Process Scheduler Simulator > An interactive educational tool for visualizing and comparing classical CPU scheduling algorithms from Operating Systems. [![React](https://img.shields.io/badge/React-18-61DAFB?logo=react&logoColor=white)](https://react.dev/) [![TypeScript](https://img.shields.io/badge/TypeScript-5-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/) [![Vite](https://img.shields.io/badge/Vite-6-646CFF?logo=vite&logoColor=white)](https://vitejs.dev/) [![Tailwind CSS](https://img.shields.io/badge/Tailwind-4-06B6D4?logo=tailwindcss&logoColor=white)](https://tailwindcss.com/) [![Vitest](https://img.shields.io/badge/Tested_with-Vitest-6E9F18?logo=vitest&logoColor=white)](https://vitest.dev/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) --- ## โœจ What is it? The **Process Scheduler Simulator (PSS)** runs entirely in the browser, completely free of servers and system dependencies. You define the processes, choose the algorithm, and watch the simulation unfold in real time through the Gantt chart. Ideal for: - ๐Ÿ“š Operating Systems students who want to visualize what was once only theory - ๐Ÿ‘ฉโ€๐Ÿซ Instructors looking for an interactive classroom tool - ๐Ÿ” Professionals revisiting OS fundamentals A live demo is available at: **https://pss.lucasrguerra.dev.br/** --- ## ๐Ÿš€ Quick Start ### Prerequisites - [Node.js](https://nodejs.org/) 20+ - npm 10+ ### Local installation and run ```bash # Clone the repository git clone https://github.com/lucasrguerra/pss.git cd pss # Install dependencies npm install # Start the development server npm run dev ``` Open [http://localhost:5173](http://localhost:5173) in your browser. ### Production build ```bash npm run build npm run preview ``` ### With Docker ```bash docker compose up ``` --- ## ๐ŸŽฎ How to use 1. **Create your processes**: In the left panel, add processes by defining name, arrival time, priority, and a sequence of bursts (CPU and I/O). Or use the random generator to get started quickly. 2. **Configure the scheduler**: Choose an algorithm and adjust the parameters (quantum for RR, aging for Priority, etc.). 3. **Run the simulation**: Use the Play/Pause/Step controls to run the simulation at the speed you want (0.25ร— to 4ร—). 4. **Analyze the results**: The Gantt chart shows each process's state in real time. At the end, the metrics panel displays turnaround, waiting time, throughput, and more. > ๐Ÿ’ก **Tip:** Load one of the built-in **presets** to see classic phenomena such as the FCFS convoy effect or priority starvation. --- ## โš™๏ธ Supported Algorithms | Algorithm | Preemptive? | Parameters | |-----------|:-----------:|------------| | **FCFS**: First Come, First Served | โŒ | None | | **SJF**: Shortest Job First | โŒ | None | | **SRTF**: Shortest Remaining Time First | โœ… | None | | **Round Robin (RR)** | โœ… | Quantum | | **Priority NP**: Non-Preemptive Priority | โŒ | Aging (optional) | | **Priority P**: Preemptive Priority | โœ… | Aging (optional) | | **HRRN**: Highest Response Ratio Next | โŒ | None | | **Multilevel Queue** | โœ… | Quantum per queue | > See the [algorithms documentation](./docs/algorithms.en.md) for details on how each one works. --- ## ๐Ÿ“Š Computed Metrics For each simulated process, PSS automatically computes: - **Response Time**: time until the first CPU usage - **Turnaround Time**: total time from arrival to completion - **Waiting Time**: total time spent in the Ready queue - **CPU Time / I/O Time**: effective time in each type of burst - **CPU Utilization**: percentage of turnaround time spent on CPU - **Bound Type**: automatic classification as CPU Bound, I/O Bound, or Balanced Globally: averages for response/turnaround/waiting, throughput, and overall CPU utilization. --- ## ๐Ÿ—‚๏ธ Project Structure ``` src/ โ”œโ”€โ”€ core/ # Pure logic (no React) โ”‚ โ”œโ”€โ”€ algorithms/ # Implementation of each algorithm โ”‚ โ”‚ โ”œโ”€โ”€ base.ts # Abstract class BaseScheduler โ”‚ โ”‚ โ”œโ”€โ”€ fcfs.ts โ”‚ โ”‚ โ”œโ”€โ”€ sjf.ts โ”‚ โ”‚ โ”œโ”€โ”€ rr.ts โ”‚ โ”‚ โ”œโ”€โ”€ priority.ts โ”‚ โ”‚ โ”œโ”€โ”€ priority_rr.ts โ”‚ โ”‚ โ”œโ”€โ”€ hrrn.ts โ”‚ โ”‚ โ”œโ”€โ”€ multilevel.ts โ”‚ โ”‚ โ””โ”€โ”€ index.ts # Dispatch by algorithm โ”‚ โ”œโ”€โ”€ engine.ts # SimulationEngine, orchestrates the ticks โ”‚ โ”œโ”€โ”€ metrics.ts # Per-process and global metrics computation โ”‚ โ”œโ”€โ”€ types.ts # All TypeScript interfaces โ”‚ โ””โ”€โ”€ presets.ts # Pre-defined scenarios โ”‚ โ”œโ”€โ”€ store/ # Global state with Zustand โ”œโ”€โ”€ components/ # React components โ”‚ โ”œโ”€โ”€ ProcessPanel/ # Process creation and editing โ”‚ โ”œโ”€โ”€ SchedulerPanel/ # Algorithm selection and parameters โ”‚ โ”œโ”€โ”€ ControlBar/ # Play, Pause, Step, Reset, speed โ”‚ โ”œโ”€โ”€ GanttChart/ # Interactive Gantt chart โ”‚ โ”œโ”€โ”€ MetricsPanel/ # Table, charts, and global metrics โ”‚ โ””โ”€โ”€ shared/ # Buttons, badges, tooltips, modals โ”‚ โ””โ”€โ”€ hooks/ # Custom hooks (animation loop, export, etc.) ``` --- ## ๐Ÿ“ฆ Available Presets Load classic scenarios with a single click to explore OS phenomena: | Preset | What it demonstrates | |--------|----------------------| | `classic_fcfs` | Basic execution with FCFS, no I/O | | `convoy_effect` | Convoy effect: one long process blocking many short ones | | `rr_demo` | Fair time-sharing with Round Robin (quantum=3) | | `starvation` | Low-priority processes never receive CPU | | `aging_fix` | The same starvation scenario, solved with aging | | `io_heavy` | Mix of CPU Bound vs. I/O Bound processes | | `multilevel_demo` | Multiple queues with different priorities | --- ## ๐Ÿงช Tests ```bash # Run all unit tests npm test # Watch mode (re-runs on save) npm run test:watch # With coverage report npm run test:coverage ``` Tests cover the simulation engine, all scheduling algorithms, and metrics computation. --- ## ๐Ÿ› ๏ธ Technology Stack | Layer | Technology | |-------|-----------| | UI Framework | React 18 | | Language | TypeScript 5 | | Build tool | Vite 6 | | Styling | Tailwind CSS 4 | | Global state | Zustand 5 | | Charts | Recharts | | Icons | Lucide React | | Testing | Vitest + Testing Library | --- ## ๐Ÿ“„ Additional Documentation - [๐Ÿ“ Scheduling Algorithms](./docs/algorithms.en.md): detailed description of each algorithm, tie-breaking rules, and examples - [๐Ÿ“ Metrics](./docs/metrics.en.md): formulas and definitions for all computed metrics - [๐Ÿ“ JOSS Paper](./paper.md): scientific paper submitted to the Journal of Open Source Software *Tambรฉm disponรญvel em: [๐Ÿ‡ง๐Ÿ‡ท Portuguรชs](./README.md)* --- ## ๐Ÿค Contributing Contributions are welcome! Please read our [CONTRIBUTING.md](./CONTRIBUTING.md) guide for details on our code of conduct, and the process for submitting Pull Requests to us. --- ## ๐Ÿ“œ License Distributed under the [MIT License](./LICENSE). Developed by [Lucas Rayan Guerra](https://github.com/lucasrguerra).