CPU scheduling
Type in your processes with their arrival and burst times, pick an algorithm and watch how the operating system shares out the CPU: the Gantt chart is drawn step by step, with the ready queue and the reason behind every decision. Waiting, turnaround and response times work themselves out, with their averages. It runs in your browser, on your phone too.
How to use it
- Write the processes in
processes.txt: a name, the instant they arrive and their CPU burst (up to 8). It starts with the “night before the deadline” ones, the same as in the theory. - Pick FCFS, SJF, SRTF or RR (with its quantum). The terminal command changes with your choice.
- Press Step to go decision by decision, or Run to watch it all. At each step you see who gets the CPU, what the ready queue looks like and why.
- Below, the results table and a comparison of the four algorithms with the same processes. Share copies a link with your processes.
How to read the Gantt chart
The CPU row is the Gantt chart from the exam: one block each time a process holds the CPU, with the switch instants underneath. The rows for each process unfold the same information: the solid stretch is when it is on the CPU and the striped one is when it waits in the ready queue. The triangle marks when it arrives. If the CPU has nobody to run, the gap is striped in grey as idle.
Once the Gantt chart is drawn, the sums are always the same: turnaround = finish − arrival, waiting = turnaround − burst and response = first time on the CPU − arrival. The average is the total divided by the number of processes.
The rules it follows
- Ties: whoever arrived first goes first and, if they arrived together, the one higher in the table.
- SJF never preempts: it only decides when the CPU is free, and picks the shortest burst in the queue.
- SRTF preempts only if the newcomer is strictly shorter than what the running process has left. On a tie, it does not preempt.
- Round Robin: if a process arrives just as another one uses up its quantum, the newcomer goes first in the queue. If the quantum runs out and nobody is waiting, the same process carries on with a new quantum.
- One core, times in milliseconds and negligible context switches, as in the IC2 exercises.
Which algorithm wins
With the example processes, the average waiting time is 8.75 ms with FCFS, 6.5 with SJF, 5 with SRTF and 10 with Round Robin and a quantum of 3. SRTF wins on waiting because it runs the short ones first, but a long process can be left waiting forever if short ones keep arriving (starvation). Round Robin waits longer on average and, in exchange, nobody waits more than Q × (N − 1) to get the CPU for the first time: its average response time is just 3 ms. Try changing the quantum and watch the comparison.

What is an operating system — theory with your laptop on a study afternoon, a write() call and a CPU that never rests (and the three programs that weren’t running at the same time)