CPU Scheduling Simulator
Simulate FCFS, SJF, SRTF, Round Robin and Priority scheduling with Gantt chart.
—ms
Avg WT
—ms
Avg TAT
—%
CPU Util
Algorithm
FCFS — Non-Preemptive
First Come First Served — processes execute in arrival order. Simple but can cause convoy effect.
Processes
| Process | Arrival Time | Burst Time | Priority | |
|---|---|---|---|---|
Algorithm Comparison
| Algorithm | Preemptive | Starvation | Overhead | Best For |
|---|---|---|---|---|
| FCFS | No | No | Low | Batch systems |
| SJF | No | Yes | Medium | Batch with known burst |
| SRTF | Yes | Yes | High | Interactive systems |
| RR | Yes | No | Medium | Time-sharing OS |
| Priority | No | Yes | Medium | Real-time systems |
Interview Questions
Q: What is the convoy effect in FCFS?
A: When a long process holds the CPU, causing shorter processes to wait — leading to poor average waiting time.
Q: Why is SJF optimal for average waiting time?
A: By always picking the shortest job, it minimizes the total waiting time across all processes.
Q: What is the difference between SJF and SRTF?
A: SJF is non-preemptive (runs to completion), SRTF is preemptive (can be interrupted by a shorter job).
Q: What happens if quantum is too large in Round Robin?
A: It degenerates to FCFS. If too small, context switching overhead becomes significant.
Q: What is aging in priority scheduling?
A: Gradually increasing the priority of waiting processes to prevent starvation.