willardcsoriano/SRTF-Manual-5Job-Trace
An interactive web tool for simulating and manually verifying the Shortest Remaining Time First (SRTF) CPU scheduling algorithm with dynamic Gantt chart visualization and computed performance metrics.
SRTF Manual Trace (5 Jobs)
A clean, interactive web tool designed to simulate and manually verify the Shortest-Remaining-Time-First (SRTF) CPU scheduling algorithm.
This project is built with a fully modular ES-module architecture, making the core logic, UI rendering, and app flow maintainable and scalable.
๐ Live Demo
๐ Try it here:
๐ https://willardcsoriano.github.io/SRTF-Manual-5Job-Trace/
Runs entirely in the browser โ no install needed.
๐ฏ Purpose
This tool was created for Modeling and Simulation Theory โ ASS2.1 (Manual SRTF) to help students:
- Understand preemptive shortest-job scheduling
- Validate manual SRTF computations
- Observe real-time CPU timeline execution
- Analyze turnaround and waiting times
๐ Features
โ Full SRTF Scheduling Simulation
- Preemptive shortest remaining time
- Automatically detects and handles preemptions
- CPU timeline updates dynamically
โ Rich Visualization
- Gantt chart with color-coded process segments
- Process Input Table (AT, BT)
- Final Metrics Table (AT, BT, CT, TAT, WT)
- Sortable columns
- Average WT and TAT summary
โ Modular Architecture (ES Modules)
js/
โโโ app.js # Main controller
โโโ core/ # Pure scheduling logic
โ โโโ process.js
โ โโโ utils.js
โ โโโ srtf.js
โ โโโ metrics.js
โโโ ui/ # Rendering components
โโโ inputTable.js
โโโ metricsTable.js
โโโ gantt.js
โโโ sort.js
โ Modern UI/UX
- TailwindCSS styling
- Responsive layout
- MathJax for algorithm notation
๐ง Algorithm Explanation: SRTF
SRTF (Shortest Remaining Time First) is a preemptive version of SJF.
Key Principle
At any time t, the CPU selects the process with the smallest remaining burst time.
When Preemption Happens
If a new process arrives with a burst time shorter than the remaining time of the currently running process:
if BT_new < remaining_time_current:
preempt current
run new process
Performance Metrics
For each process P:
Turnaround Time (TAT) = Completion Time - Arrival Time
Waiting Time (WT) = TAT - Burst Time
This tool computes all metrics automatically.
๐ธ Screenshots (Preview)
Input & Instructions Section
Gantt Chart
Final Metrics Table
๐ ๏ธ Setup for Local Development
Because this project uses ES Modules, you must run it from a local server.
Option 1 โ VS Code Live Server (Recommended)
- Open folder in VS Code
- Right-click
index.htmlโ Open with Live Server
Option 2 โ Python
python -m http.server 3000Visit:
http://localhost:3000/
Option 3 โ Node http-server
npm install -g http-server
http-server .๐ Folder Structure
SRTF-Manual-5Job-Trace/
โ index.html
โ favicon.png
โ styles.css
โ README.md
โ
โโโ js/
โโโ app.js
โโโ core/
โ process.js
โ utils.js
โ srtf.js
โ metrics.js
โ
โโโ ui/
inputTable.js
metricsTable.js
gantt.js
sort.js
๐งช How to Use
-
Open the Live Demo (or run locally)
-
Click Run Simulation & Generate Trace
-
View:
- Input Process Table
- Gantt Chart
- Final Metrics Table
- Average WT & TAT
Arrival times are randomized for each session to encourage manual re-validation.
๐ค Contributing
Contributions are welcome! You can help by:
- Improving UI/UX
- Adding new scheduling algorithms (FCFS, RR, Priority, etc.)
- Adding export options (CSV, PDF, PNG)
- Improving visualizations
- Adding unit tests for srtf.js
๐ License
This project is for educational use.
You may reuse parts for your own coursework or teaching.