Skip to content

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

License

Notifications You must be signed in to change notification settings

Premity/process-scheduling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Languages