CPU SchedulerTry Simulator
01Operating Systems Project

DynamicCPUSchedulingSimulator

An interactive visualization tool that brings Operating System scheduling concepts to life through real-time simulation and analysis.

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

Implement FCFS, SJF (Preemptive), Round Robin, and Priority 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, Round Robin, Priority algorithms
  • 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

Our simulator implements four fundamental CPU scheduling algorithms, each with distinct characteristics and use cases.

FCFSNon-Preemptive

First Come First Serve

The simplest scheduling algorithm. Processes are executed in the exact order they arrive in the ready queue.

Formula: Waiting Time = Start Time - Arrival Time

Best for: Batch processing systems 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
SJFPreemptive (SRTF)

Shortest Job First

Selects the process with the smallest remaining burst time. Our implementation uses preemptive SJF (Shortest Remaining Time First).

Formula: Always picks min(remaining_burst_time)

Best for: Systems where burst times are predictable and minimizing wait time is critical.

Advantages

  • Minimum average waiting time
  • Optimal for batch systems
  • Efficient CPU utilization

Disadvantages

  • Requires burst time prediction
  • May cause starvation
  • Overhead of tracking remaining time
RRPreemptive

Round Robin

Each process gets a fixed time slice (quantum). After the quantum expires, the process is moved to the back of the queue.

Formula: Context Switches ≈ Total Burst / Quantum

Best for: Time-sharing systems and interactive applications requiring responsiveness.

Advantages

  • Fair CPU allocation
  • Good response time
  • No starvation

Disadvantages

  • High context switch overhead
  • Performance depends on quantum
  • Higher turnaround for long processes
PriorityNon-Preemptive

Priority Scheduling

Each process is assigned a priority. The CPU is allocated to the process with the highest priority (lower number = higher priority).

Formula: Next Process = min(priority) from ready queue

Best for: Real-time systems where certain processes must complete before others.

Advantages

  • Flexible prioritization
  • Good for real-time systems
  • Important tasks run first

Disadvantages

  • May cause starvation
  • Priority inversion problem
  • Requires priority assignment logic
07

Implementation Progress

Completed Features

  • FCFS Algorithm - Non-preemptive, arrival-order execution
  • SJF Algorithm - Preemptive (SRTF) with dynamic re-evaluation
  • Round Robin - Time-sliced execution with configurable quantum
  • Priority Scheduling - Non-preemptive priority-based selection
  • 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
  • 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.