Skip to content

vivekvattem/cpu-scheduling-algorithms

Repository files navigation

CPU Scheduling Algorithm Visualizer

An interactive web application for visualizing and analyzing different CPU scheduling algorithms. Perfect for learning how operating systems allocate CPU time to processes.

Features

  • Four Scheduling Algorithms

    • FCFS (First Come First Served)
    • SJF (Shortest Job First)
    • Round Robin (RR)
    • Priority Scheduling
  • Interactive Visualizations

    • Animated Gantt Chart with play/pause controls
    • CPU Activity Timeline
    • Process Flow Diagram
    • Algorithm Comparison Table
  • Comprehensive Metrics

    • Average Waiting Time
    • Average Turnaround Time
    • CPU Utilization
    • Context Switches
    • Per-process statistics
  • Data Export

    • CSV format for spreadsheets
    • JSON format for integration
    • TXT format for documentation
  • User-Friendly Interface

    • Preset process loads (Light, Medium, Heavy)
    • Custom process creation
    • Real-time algorithm comparison
    • Interactive help system

Getting Started

Quick Start

  1. Open the application in your browser
  2. Choose a scheduling algorithm from the dropdown
  3. Click "Run Scheduler" to visualize the scheduling
  4. Explore the results with interactive charts

Adding Custom Processes

  1. Click the "Add Process" tab
  2. Enter Process ID (e.g., P1)
  3. Enter Arrival Time and Burst Time
  4. For Priority scheduling, enter Priority value
  5. Click "Add Process"

Using Presets

  1. Click the "Presets" tab
  2. Select Light, Medium, or Heavy load
  3. Processes are automatically added

Understanding Algorithms

FCFS (First Come First Served)

  • Processes execute in order of arrival
  • Simple but may cause starvation for short processes
  • Best for batch systems

SJF (Shortest Job First)

  • Process with shortest burst time executes first
  • Minimizes average waiting time
  • Risk of starvation for long processes

Round Robin (RR)

  • Each process gets a time quantum (default: 3)
  • Fair scheduling, prevents starvation
  • Higher context switching overhead
  • Best for interactive systems

Priority Scheduling

  • Processes execute by priority (lower value = higher priority)
  • Can be preemptive or non-preemptive
  • Risk of starvation for low-priority processes
  • Best for real-time systems

Metrics Explained

  • Waiting Time: Time process waits in queue before execution
  • Turnaround Time: Total time from arrival to completion
  • CPU Utilization: Percentage of time CPU is busy
  • Context Switches: Number of times CPU switches processes

Exporting Results

After running the scheduler, export your results:

  • CSV: Open in Excel or Google Sheets for analysis
  • JSON: Use for integration or programmatic analysis
  • TXT: Human-readable format for documentation

Exports include:

  • All process information
  • Execution schedule
  • Overall statistics
  • Per-process metrics

Tips & Best Practices

  1. Start Simple: Begin with default processes to understand basics
  2. Compare Algorithms: Run the same processes with different algorithms
  3. Test Under Load: Use presets to test algorithms under different loads
  4. Analyze Trade-offs: Compare metrics to understand algorithm strengths/weaknesses
  5. Custom Scenarios: Create specific scenarios matching your use case

Algorithm Comparison

Use the comparison table to quickly see which algorithm performs best for your process set:

  • Green highlight shows best performance
  • Compare waiting time, turnaround time, and total execution time
  • Identify the most suitable algorithm for your scenario

Help & Documentation

  • Click the Help (?) button for interactive guidance
  • Hover over descriptions for more details
  • Read the About section for comprehensive information
  • Check algorithm descriptions for detailed explanations

Use Cases

Educational

  • Learning operating system concepts
  • Understanding process scheduling
  • Comparing algorithm performance

Professional

  • System optimization analysis
  • Performance evaluation
  • Documentation and reporting

Research

  • Algorithm comparison studies
  • Performance benchmarking
  • System design analysis

Troubleshooting

No results showing?

  • Ensure you have processes added
  • Click "Run Scheduler" after selecting an algorithm

Results look unexpected?

  • Check process arrival and burst times
  • Verify algorithm selection
  • Review algorithm descriptions

Export not working?

  • Ensure you have run the scheduler
  • Check browser's download settings
  • Try a different export format

Future Enhancements

  • Additional scheduling algorithms
  • Process preemption support
  • Advanced filtering and sorting
  • Custom time quantum configurations
  • Performance comparison charts
  • Historical result tracking

Technology Stack

  • React / Next.js 16
  • TypeScript
  • Canvas API for visualizations
  • Tailwind CSS for styling
  • shadcn/ui for components

License

Educational use - Feel free to use for learning and teaching purposes.


Happy scheduling! 🚀

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors