A comprehensive, interactive web-based simulator for CPU scheduling algorithms with real-time visualization and performance metrics.
-
First-Come, First-Served (FCFS)
- Non-preemptive scheduling
- Processes executed in arrival order
- Simple queue-based approach
-
Shortest Job First (SJF)
- Non-preemptive version
- Process with smallest burst time runs first
- Optimal for minimizing average waiting time
-
Shortest Remaining Time First (SRTF)
- Preemptive version of SJF
- Process with shortest remaining time gets CPU
- Most optimal for minimizing average waiting time
-
Round Robin (RR)
- Preemptive scheduling with time quantum
- Each process gets fixed time slice
- Fair scheduling for time-sharing systems
-
Priority Scheduling
- Non-preemptive version
- Higher priority (lower number) processes run first
- Configurable priority levels (1-10)
-
Priority Scheduling (Preemptive)
- Preemptive version of priority scheduling
- Higher priority processes can preempt running processes
-
Highest Response Ratio Next (HRRN)
- Non-preemptive algorithm
- Selects process with highest response ratio
- Response Ratio = (Waiting Time + Burst Time) / Burst Time
-
Multilevel Queue Scheduling
- Two priority levels (High: 1-5, Low: 6-10)
- High priority processes get preference
- Simple implementation for demonstration
-
Multilevel Feedback Queue
- Similar to multilevel queue with aging
- Processes can change priority based on waiting time
- Prevents starvation
- Queue: Used for FCFS and general process management
- Stack: Available for future implementations
- Priority Queue: Used for priority-based scheduling
- Arrays: Used for process storage and sorting
- Real-time Gantt Chart: Visual representation of process execution
- Process Table: Shows current status of all processes
- Performance Metrics: Live calculation of:
- Average Waiting Time
- Average Turnaround Time
- Average Response Time
- CPU Utilization
- Throughput
- Total Execution Time
- Detailed Results Table: Complete breakdown of each process's metrics
- Interactive Timeline: Time markers for easy tracking
- Modern, Responsive Design: Works on desktop and mobile devices
- Interactive Controls: Start, pause, resume, reset, and step-by-step execution
- Toast Notifications: Real-time feedback for user actions
- Color-coded Processes: Each process has a unique color in the Gantt chart
- Status Indicators: Visual status badges for process states
- Open the Application: Simply open
index.htmlin any modern web browser - Add Processes: Use the process input form to add processes with:
- Process Name (e.g., P1, P2)
- Arrival Time (when process arrives)
- Burst Time (execution time needed)
- Priority (1-10, lower number = higher priority)
- Select Algorithm: Choose from the dropdown menu
- Configure Settings: For Round Robin, set the time quantum
- Start Simulation: Click "Start" to begin automatic execution
- Control Execution:
- Pause/Resume: Temporarily stop or continue simulation
- Step: Execute one time unit at a time
- Reset: Clear all results and start over
- Gantt Chart: Shows the execution order and timing
- Statistics Cards: Display real-time performance metrics
- Results Table: Detailed breakdown for each completed process
- Process Table: Current status of all processes
- Time a process spends waiting in the ready queue
- Calculated as: Completion Time - Arrival Time - Burst Time
- Total time from arrival to completion
- Calculated as: Completion Time - Arrival Time
- Time from arrival to first CPU allocation
- Important for interactive systems
- Percentage of time CPU is busy
- Calculated as: (Total Burst Time / Total Time) × 100
- Number of processes completed per time unit
- Calculated as: Number of Processes / Total Time
| Algorithm | Preemptive | Average Waiting Time | CPU Utilization | Fairness |
|---|---|---|---|---|
| FCFS | No | High | Medium | High |
| SJF | No | Low | Medium | Low |
| SRTF | Yes | Lowest | Medium | Low |
| Round Robin | Yes | Medium | High | High |
| Priority | No | Medium | Medium | Low |
| HRRN | No | Low | Medium | Medium |
- Frontend: HTML5, CSS3, JavaScript (ES6+)
- No Dependencies: Pure vanilla JavaScript
- Responsive Design: CSS Grid and Flexbox
- Real-time Updates: DOM manipulation for live visualization
Process: Represents individual processes with all propertiesQueue: FIFO data structure for process managementStack: LIFO data structure (available for future use)PriorityQueue: Priority-based queue implementationScheduler: Main orchestrator class handling all algorithms
Each algorithm is implemented as a separate method in the Scheduler class:
executeFCFS(): First-Come, First-ServedexecuteSJF(): Shortest Job FirstexecuteSRTF(): Shortest Remaining Time FirstexecuteRoundRobin(): Round Robin with time quantumexecutePriority(): Non-preemptive priority schedulingexecutePriorityPreemptive(): Preemptive priority schedulingexecuteHRRN(): Highest Response Ratio NextexecuteMultilevelQueue(): Multilevel queue schedulingexecuteMultilevelFeedback(): Multilevel feedback queue
- Add the algorithm name to the HTML dropdown
- Implement the execution method in the Scheduler class
- Add the case in the
executeStep()method - Update the algorithm selection event listener if needed
- Modify
styles.cssfor visual changes - Process colors are defined in CSS classes (
.process-p1,.process-p2, etc.) - Responsive breakpoints are defined for mobile devices
- Adjust
simulationSpeedin the Scheduler constructor - Modify the time quantum for Round Robin
- Change the aging threshold in multilevel feedback queue
- More Algorithms: Add more scheduling algorithms
- Process I/O: Implement I/O-bound processes
- Multiple CPUs: Simulate multi-processor systems
- Process Dependencies: Add process precedence constraints
- Export Results: Save simulation results to file
- Algorithm Comparison: Side-by-side algorithm comparison
- Custom Process Sets: Save and load process configurations
This project is open source and available under the MIT License.
Feel free to contribute by:
- Adding new scheduling algorithms
- Improving the UI/UX
- Fixing bugs
- Adding new features
- Improving documentation
Happy Scheduling! 🎉