GitHunt
PR

Premity/process-scheduling

A CPU Scheduling Simulator running on WebAssembly. Visualizes FCFS, SJF, RR, and Priority scheduling algorithms in the browser

CPU Scheduler Simulator

An interactive CPU scheduling simulator with a WebAssembly-powered web interface.

C++17
WebAssembly
License


Features

  • Six Scheduling Algorithms: FCFS, SJF, SRTF, Round Robin, Priority (Preemptive & Non-Preemptive)
  • Aging Mechanism: Configurable priority boost to prevent starvation
  • Interactive Web UI
    • Real-time Gantt Chart
    • Live Ready Queue visualization
    • Process Statistics with color-coded states
    • Light/Dark Mode Toggle
    • Table-based process input
  • Metrics: Waiting Time, Turnaround Time, Response Time

Quick Start

๐Ÿง Linux / macOS

  1. Dependencies: Install git, python3, cmake, and g++.
# Ubuntu/Debian
sudo apt update
sudo apt install git python3 cmake g++
  1. Install Emscripten:
git clone https://github.com/emscripten-core/emsdk.git && cd emsdk
./emsdk install latest && ./emsdk activate latest
source ./emsdk_env.sh
cd ..
  1. Build:
git clone https://github.com/Premity/process-scheduling.git
cd process-scheduling
mkdir build && cd build
emcmake cmake .. && emmake make
cp scheduler_wasm.js scheduler_wasm.wasm ../www/
  1. Run:
cd ..
g++ -std=c++17 src/server_main.cpp -o scheduler_server -I include -lpthread
./scheduler_server

๐ŸชŸ Windows (PowerShell)

  1. Prerequisites:

  2. Install Emscripten:

git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
./emsdk_env.bat
cd ..
  1. Build:
git clone https://github.com/Premity/process-scheduling.git
cd process-scheduling
mkdir build; cd build
emcmake cmake -G "MinGW Makefiles" ..
emmake mingw32-make
Copy scheduler_wasm.js ..\www\
Copy scheduler_wasm.wasm ..\www\
  1. Run:
cd ..
# Compile server (linking ws2_32 for Windows sockets)
g++ -std=c++17 src/server_main.cpp -o scheduler_server.exe -I include -lws2_32 -static
scheduler_server.exe

Project Structure

.
โ”œโ”€โ”€ cmake/                # CMake configuration
โ”œโ”€โ”€ include/
โ”‚   โ”œโ”€โ”€ scheduler.h       # Core scheduler API
โ”‚   โ”œโ”€โ”€ httplib.h         # cpp-httplib (header-only)
โ”‚   โ””โ”€โ”€ json.hpp          # nlohmann/json (header-only)
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ scheduler.cpp     # Scheduler implementation
โ”‚   โ”œโ”€โ”€ wasm_main.cpp     # WebAssembly bindings
โ”‚   โ””โ”€โ”€ server_main.cpp   # Native C++ static file server
โ”œโ”€โ”€ www/                  # Web UI (HTML, CSS, JS)
โ”œโ”€โ”€ CMakeLists.txt
โ”œโ”€โ”€ LICENSE
โ””โ”€โ”€ README.md

Scheduling Algorithms

Algorithm Type Selection Criteria
FCFS Non-Preemptive Earliest arrival
SJF Non-Preemptive Shortest burst time
SRTF Preemptive Shortest remaining time
Round Robin Preemptive Time quantum rotation
Priority Preemptive Lowest priority value
PriorityNP Non-Preemptive Lowest priority value

Aging Mechanism

Prevents starvation by boosting priority of waiting processes:

scheduler.setAging(true);
scheduler.setAgingThreshold(5);    // Boost every 5 ticks
scheduler.setAgingBoostAmount(1);  // Decrease priority by 1

Dependencies

  • C++17 Compiler (GCC/Clang/MSVC)
  • CMake 3.10+
  • Emscripten SDK (for WebAssembly build)
  • nlohmann/json (included in include/)
  • cpp-httplib (included in include/)

License

MIT License โ€” see LICENSE


Author

Mohammad Hamd Ashfaque
GitHub: @Premity


Version: 1.0.0 | Last Updated: December 2025

Languages

C++88.8%JavaScript9.6%CSS0.9%HTML0.5%CMake0.2%

Contributors

MIT License
Created December 7, 2025
Updated December 28, 2025
Premity/process-scheduling | GitHunt