Skip to content

ali2943/Multi-Algorithm-Scheduler-Simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Multi-Algorithm CPU Scheduler Simulator

A comprehensive CPU scheduling algorithm simulator with both Web GUI (React) and CLI interfaces. This project implements and visualizes multiple scheduling algorithms with interactive Gantt charts and automated metrics calculation.

🎯 Features

Scheduling Algorithms Implemented

  1. FCFS - First Come First Serve
  2. SJF - Shortest Job First (Non-preemptive)
  3. SRTF - Shortest Remaining Time First (Preemptive SJF)
  4. RR - Round Robin (configurable time quantum)
  5. Priority - Priority Scheduling (preemptive and non-preemptive)
  6. MLQ - Multi-Level Queue
  7. MLFQ - Multi-Level Feedback Queue

Key Features

  • πŸ“Š Interactive Gantt Charts - Visual timeline of process execution
  • πŸ“ˆ Automated Metrics - Average waiting time, turnaround time, CPU utilization
  • 🌐 Web GUI - Beautiful, responsive React-based interface
  • πŸ’» CLI Interface - Command-line tool for automation and scripting
  • βš™οΈ Configurable Parameters - Time quantum, priorities, queue levels
  • πŸ“± Responsive Design - Works on desktop, tablet, and mobile

πŸš€ Quick Start

Prerequisites

  • Python 3.8 or higher
  • Node.js 14 or higher
  • npm or yarn

Installation

Backend Setup

cd backend
pip install -r requirements.txt

Frontend Setup

cd frontend
npm install

πŸ’» Usage

Web GUI

  1. Start the Backend Server:
cd backend
python api.py

The API server will start at http://localhost:5000

  1. Start the Frontend Development Server:
cd frontend
npm start

The web interface will open at http://localhost:3000

  1. Use the Interface:
    • Add processes with their arrival time, burst time, priority, and queue level
    • Select a scheduling algorithm
    • Configure algorithm-specific parameters (time quantum, preemptive mode, etc.)
    • Click "Run Simulation" to see the Gantt chart and metrics

CLI Interface

Run simulations from the command line:

cd backend
python cli.py --algorithm <algorithm> --processes '<json_data>'

CLI Examples

FCFS:

python cli.py --algorithm fcfs --processes '[{"pid":1,"arrival_time":0,"burst_time":4},{"pid":2,"arrival_time":1,"burst_time":3}]'

Round Robin with Time Quantum 3:

python cli.py --algorithm rr --time-quantum 3 --processes '[{"pid":1,"arrival_time":0,"burst_time":5},{"pid":2,"arrival_time":2,"burst_time":3}]'

Priority Scheduling (Non-preemptive):

python cli.py --algorithm priority --processes '[{"pid":1,"arrival_time":0,"burst_time":4,"priority":2},{"pid":2,"arrival_time":1,"burst_time":3,"priority":1}]'

Priority Scheduling (Preemptive):

python cli.py --algorithm priority --preemptive --processes '[{"pid":1,"arrival_time":0,"burst_time":4,"priority":2},{"pid":2,"arrival_time":1,"burst_time":3,"priority":1}]'

Using a JSON file:

python cli.py --algorithm sjf --file processes.json

MLFQ with custom time quantums:

python cli.py --algorithm mlfq --time-quantums "[2,4,8]" --processes '[{"pid":1,"arrival_time":0,"burst_time":10}]'

πŸ“Š Metrics Calculated

The simulator automatically calculates:

  • Average Waiting Time - Average time processes wait in ready queue
  • Average Turnaround Time - Average time from arrival to completion
  • CPU Utilization - Percentage of time CPU is actively executing processes
  • Individual Process Metrics - Waiting time, turnaround time, response time per process

πŸ—οΈ Project Structure

Multi-Algorithm-Scheduler-Simulator/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ scheduler.py       # Core scheduling algorithms implementation
β”‚   β”œβ”€β”€ api.py            # Flask REST API server
β”‚   β”œβ”€β”€ cli.py            # Command-line interface
β”‚   └── requirements.txt  # Python dependencies
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ public/
β”‚   β”‚   └── index.html    # HTML template
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/   # React components
β”‚   β”‚   β”‚   β”œβ”€β”€ GanttChart.js
β”‚   β”‚   β”‚   β”œβ”€β”€ Metrics.js
β”‚   β”‚   β”‚   └── ProcessInput.js
β”‚   β”‚   β”œβ”€β”€ utils/        # Utility functions
β”‚   β”‚   β”‚   └── api.js
β”‚   β”‚   β”œβ”€β”€ styles/       # CSS stylesheets
β”‚   β”‚   β”‚   └── App.css
β”‚   β”‚   β”œβ”€β”€ App.js        # Main React component
β”‚   β”‚   └── index.js      # React entry point
β”‚   └── package.json      # Node.js dependencies
└── README.md             # This file

πŸŽ“ Concepts Covered

CPU Scheduling

  • Non-preemptive vs Preemptive scheduling
  • Context switching
  • Process states and transitions
  • Scheduling criteria (CPU utilization, throughput, waiting time, etc.)

Data Structures

  • Process Control Block (PCB)
  • Ready queues
  • Multi-level queues
  • Priority queues

Simulation

  • Discrete event simulation
  • Gantt chart generation
  • Performance metrics calculation

πŸ”§ Configuration

Time Quantum (Round Robin)

Adjustable via GUI slider or --time-quantum CLI flag. Default: 2

Priority Levels

Lower numbers indicate higher priority. Range: 0-∞

Queue Levels (MLQ/MLFQ)

Queue 0 = highest priority. Configure time quantums per queue.

πŸ“± Screenshots

The web interface features:

  • Clean, modern design with gradient backgrounds
  • Interactive process input forms
  • Real-time Gantt chart visualization
  • Color-coded process blocks
  • Metric cards with key performance indicators

🀝 Contributing

This is an educational project. Feel free to:

  • Add more scheduling algorithms
  • Improve the UI/UX
  • Add more metrics
  • Enhance visualizations
  • Add unit tests

πŸ“ License

This project is for educational purposes as part of an Operating Systems course.

πŸ‘¨β€πŸ’» Author

OS Project - Multi-Algorithm Scheduler Simulator

πŸ™ Acknowledgments

  • Operating Systems concepts and algorithms
  • React and Flask frameworks
  • CPU scheduling theory and implementation

About

Os Project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •