CPU SchedulerTry Simulator
01Operating Systems Project

DynamicCPUSchedulingSimulator

Visualize FCFS, SJF, Round Robin, Priority, HRRN, Multilevel Queues, and I/O scheduling with animated Gantt charts and live metrics.

Scroll
02

Problem Statement

The Challenge: Understanding CPU scheduling algorithms is fundamental to Operating Systems education, yet traditional learning methods rely on static diagrams and manual calculations that fail to convey the dynamic nature of process scheduling.

The Gap: Students struggle to visualize how different algorithms behave under varying workloads, compare their performance metrics, and understand the trade-offs between efficiency, fairness, and overhead.

Our Solution: A real-time, interactive simulator that visualizes CPU scheduling algorithms with animated Gantt charts, live performance metrics, and intelligent algorithm recommendations.

03

Why CPU Scheduling Matters

CPU scheduling is the cornerstone of multiprogramming operating systems. It determines system performance, responsiveness, and resource utilization.

Resource Utilization

Maximize CPU usage to ensure the processor is never idle when processes are waiting.

Throughput

Complete as many processes as possible per unit time for efficient batch processing.

Turnaround Time

Minimize the total time from process submission to completion.

Waiting Time

Reduce time processes spend in the ready queue waiting for CPU allocation.

Response Time

Ensure quick first response for interactive systems and user experience.

Fairness

Guarantee all processes receive fair share of CPU time without starvation.

04

Project Objectives

01

Interactive Visualization

Create animated Gantt charts that show real-time process execution and context switches.

02

Multiple Algorithms

FCFS, SJF (preemptive & non-preemptive), Round Robin, Priority, HRRN, Multilevel Queue, MLFQ, and I/O-aware scheduling with accurate behavior.

03

Performance Metrics

Calculate and display waiting time, turnaround time, throughput, and context switches.

04

Smart Optimization

Build an intelligent system that detects suboptimal scheduling and suggests better algorithms.

05

Educational Tool

Provide clear explanations and comparisons to help students understand trade-offs.

06

Modern Experience

Deliver a polished, responsive web application with smooth animations and intuitive UX.

05

Feasibility & Scope

In Scope

  • FCFS, SJF, RR, Priority, HRRN, MLQ, MLFQ, I/O scheduling
  • Real-time Gantt chart visualization
  • Performance metrics calculation
  • Smart algorithm switching
  • Responsive web interface
  • REST API backend

Technical Feasibility

  • Browser-based: No installations required
  • Modern tech stack: React, TypeScript, Node.js
  • Lightweight: Fast load times, smooth animations
  • Scalable: Can add more algorithms easily
  • Educational: Suitable for classroom use
  • Open source: Fully transparent codebase
P1
P2
P3
P1
P2
P4
0
4
7
9
14
17
Time (ms) →
06

Scheduling Algorithms

Every scheduling algorithm available in the simulator is listed below. You can try each one in the simulator and compare behavior, metrics, and Gantt charts in real time.

FCFSNon-Preemptive

First Come First Serve

Processes are executed in the exact order they arrive in the ready queue.

Formula: Select process with minimum arrival time among ready.

Best for: Batch processing where simplicity is preferred over efficiency.

Advantages

  • Simple to implement
  • No starvation
  • Fair in terms of arrival order

Disadvantages

  • Convoy effect
  • High average waiting time
  • Not optimal for interactive systems
SRTFPreemptive (SRTF)

Shortest Remaining Time First (SRTF)

The process with the smallest remaining burst time is executed; preemption when a shorter job arrives.

Formula: Select process with minimum remaining burst time among ready.

Best for: Minimizing average waiting time when burst times are predictable.

Advantages

  • Minimum average waiting time (provably optimal)
  • Efficient CPU utilization

Disadvantages

  • Requires burst time prediction
  • May cause starvation of long processes
SJFNon-Preemptive

Shortest Job First (Non-preemptive)

Among ready processes, the one with the smallest burst time runs to completion. No preemption.

Formula: Select ready process with minimum burst time; run to completion.

Best for: Batch systems when jobs are known in advance.

Advantages

  • Simple
  • Minimizes average waiting when jobs known in advance

Disadvantages

  • May cause starvation of long jobs
  • Requires burst time knowledge
LJFNon-Preemptive

Longest Job First

The ready process with the largest burst time runs to completion. No preemption.

Formula: Select ready process with maximum burst time; run to completion.

Best for: Favoring long-running jobs.

Advantages

  • Simple
  • Favors long-running jobs

Disadvantages

  • May cause starvation of short jobs
  • Poor for interactive systems
LRTFPreemptive

Longest Remaining Time First

The process with the largest remaining burst time runs; preemption when a longer job arrives.

Formula: Select process with maximum remaining burst time among ready.

Best for: Preemptive favoring of long jobs.

Advantages

  • Favors long jobs in preemptive setting

Disadvantages

  • Short jobs may starve
  • High context switches
RRPreemptive

Round Robin

Each process gets a fixed time quantum; after quantum expires, it is preempted and added to the end of the ready queue.

Formula: Cyclic: run each ready process for up to quantum time units, then move to back of queue.

Best for: Time-sharing and interactive systems; fair CPU allocation.

Advantages

  • Fair allocation
  • Good for time-sharing
  • No starvation

Disadvantages

  • High context switch overhead
  • Performance depends on quantum size
PRINon-Preemptive

Priority (Non-preemptive)

The process with the highest priority (lowest number here) runs first. Once started, runs to completion.

Formula: Select ready process with highest priority (smallest priority number).

Best for: Real-time systems where certain tasks must run first.

Advantages

  • Flexible prioritization
  • Useful for real-time systems

Disadvantages

  • May cause starvation
  • Priority inversion possible
PRI+Preemptive

Priority (Preemptive)

Highest-priority process runs; preemption occurs when a higher-priority process arrives.

Formula: At each instant, run ready process with highest priority. Preempt when higher-priority arrives.

Best for: Real-time systems with dynamic priority arrivals.

Advantages

  • Responsive to high-priority jobs
  • Good for real-time

Disadvantages

  • Starvation of low-priority processes
  • Priority inversion
MLQMulti-Queue

Multilevel Queue (MLQ)

Processes are assigned to queues by priority level; each queue may use a different algorithm (e.g. RR).

Formula: Assign to queue by priority; schedule from highest-priority non-empty queue (e.g. RR within queue).

Best for: Separating workload types (e.g. system vs user) with different policies.

Advantages

  • Separation of workload types
  • Configurable per queue

Disadvantages

  • No feedback between queues
  • Can starve lower queues
HRRNNon-Preemptive

Highest Response Ratio Next

Response Ratio = (Waiting + Burst) / Burst. The ready process with highest RR runs to completion.

Formula: RR = (waiting_time + burst_time) / burst_time; select max RR among ready.

Best for: Balancing waiting time and service time; reduces starvation.

Advantages

  • Reduces starvation
  • Considers both waiting and service time

Disadvantages

  • Overhead of computing RR
  • Requires burst time
LOTProportional-Share

Lottery Scheduling

Each process gets tickets; each quantum a random ticket wins and that process runs. Proportional-share.

Formula: Pick random ticket among ready (probability ∝ tickets); run winner for quantum.

Best for: Proportional CPU share with simple ticket assignment.

Advantages

  • Simple
  • Proportional share
  • No starvation in expectation

Disadvantages

  • Variable performance
  • Requires ticket assignment
STRProportional-Share

Stride Scheduling

Deterministic proportional-share: each process has a stride (inverse of share); run process with smallest pass, then add stride.

Formula: pass += stride after run; select process with minimum pass among ready.

Best for: Deterministic proportional CPU allocation.

Advantages

  • Deterministic
  • Accurate proportional share
  • No starvation

Disadvantages

  • Requires stride computation
  • Overhead of pass updates
FCFS+I/OWith I/O

FCFS with I/O bursts

Like FCFS but processes can have multiple CPU burst / I/O burst pairs; while in I/O the process is blocked and does not use the CPU.

Formula: Bursts: [cpu1, io1, cpu2, io2, ...]. Ready = arrived and not in I/O; schedule FCFS among ready.

Best for: Realistic I/O-bound workloads and blocking behavior.

Advantages

  • Realistic for I/O-bound workloads
  • Teaches blocking behavior

Disadvantages

  • Requires burst list per process
MLFQMulti-Queue + Feedback

Multilevel Feedback Queue (MLFQ)

Processes start in the top queue; if they use a full time slice they are demoted to a lower queue.

Formula: Start in top queue; after using full quantum, demote to next queue. Schedule from highest non-empty queue (e.g. RR).

Best for: Favoring short and I/O-bound jobs without prior knowledge.

Advantages

  • Favors short and I/O-bound jobs
  • Adapts without prior knowledge

Disadvantages

  • Complex tuning
  • Possible starvation in lower queues
CUSTOMUser-Defined

Custom (user-defined)

Run your own scheduling strategy in the browser: JavaScript that receives ready processes and current time and returns which process to run.

Formula: function(state) => pid; state has ready processes and time.

Best for: Experiments and custom scheduling logic in JavaScript.

Advantages

  • Experiments and assignments
  • No server needed

Disadvantages

  • Requires writing code
  • Client-side only
07

Implementation Progress

Completed Features

  • FCFS - Non-preemptive, arrival-order execution
  • SJF - Preemptive (SRTF) and non-preemptive variants
  • Round Robin - Time-sliced execution with configurable quantum
  • Priority - Preemptive and non-preemptive priority scheduling
  • HRRN - Highest Response Ratio Next
  • MLQ / MLFQ - Multilevel and Multilevel Feedback Queues
  • FCFS + I/O - I/O bursts and CPU-I/O overlap
  • Smart Switcher - Automatic algorithm optimization
  • Metrics Engine - Wait time, turnaround, context switches
  • Gantt Chart - Animated timeline visualization
  • Real-time Updates - Live results as inputs change
  • Modern UI - Dark theme with smooth animations
  • REST API - Express backend with TypeScript

Tech Stack

React 18

UI Library

TypeScript

Type Safety

Vite

Build Tool

Tailwind

Styling

Framer Motion

Animations

MUI Charts

Data Viz

Express

Backend

Node.js

Runtime

08

System Architecture

Frontend

React SPA with real-time updates

  • Landing Page (Presentation)
  • Simulator Page (Input + Results)
  • Gantt Chart Component
  • MUI X Charts Integration
  • Framer Motion Animations

API Layer

RESTful endpoints for simulation

  • POST /api/simulate
  • Request validation
  • Algorithm routing
  • Response formatting
  • Error handling

Backend Logic

Core algorithms & metrics engine

  • FCFS, SJF, RR, Priority, HRRN, MLQ, MLFQ, I/O
  • Metrics Calculator
  • Smart Switcher/Evaluator
  • Gantt Chart Generator
  • Process Result Builder

Data Flow Pipeline

User InputAPI RequestAlgorithmEvaluatorResults
09

Key Formulas & Metrics

Completion Time (CT)

Time when process finishes

Example: CT = End time in Gantt chart

Turnaround Time (TAT)

CT - Arrival Time

Example: TAT = 10 - 2 = 8 units

Waiting Time (WT)

TAT - Burst Time

Example: WT = 8 - 5 = 3 units

Average Waiting Time

Σ(WT) / n

Example: (3 + 5 + 2) / 3 = 3.33

Throughput

n / Total Time

Example: 5 processes / 20 units = 0.25

CPU Utilization

(Busy Time / Total Time) × 100

Example: (18 / 20) × 100 = 90%

10

OS Concepts Demonstrated

CPU Scheduling

Algorithm selection, process ordering, ready queue management

Context Switching

Process state saving, overhead measurement, switch optimization

Performance Metrics

Wait time, turnaround time, throughput, CPU utilization

Process Management

Process states, arrival modeling, burst time simulation

Time Quantum

Time-slicing, preemption intervals, quantum selection

Priority Systems

Priority assignment, scheduling decisions, starvation prevention

Optimization

Algorithm comparison, trade-off analysis, workload adaptation

Preemption

Preemptive vs non-preemptive, SRTF implementation, state management

11

Smart Algorithm Switching

Our intelligent evaluator detects suboptimal scheduling and automatically recommends better algorithms.

Round Robin → SJF

When context switches exceed threshold:

// Detection

if (contextSwitches > processes.length × 2.5)

→ Switch to SJF

Example

"Round Robin caused 8 context switches. System switched to SJF to reduce turnaround time by 25%."

FCFS → SJF

When convoy effect causes high waiting time:

// Detection

if (fcfsWaitTime > sjfWaitTime × 2)

→ Switch to SJF

Example

"FCFS led to high average waiting time (12.5). System switched to SJF (avg waiting: 4.2)."

12Try It Now

Experience the Simulator

Configure processes, select an algorithm, and watch the scheduling unfold in real-time with animated Gantt charts and live metrics.