The four times, and how to get them
- Completion time (CT): when the process finishes.
- Turnaround time (TAT) = CT − arrival time. All the time it spent in the system.
- Waiting time (WT) = TAT − burst time. The time it was ready but not running.
- Response time (RT) = first run − arrival time. How long until it first got the CPU.
If your waiting times don't match, check the turnaround times first: waiting time is always TAT − BT.
The algorithms, one line each
- FCFS (first come, first served) runs processes in the order they arrive. Simple, but one long process makes everyone behind it wait: the convoy effect. Non-preemptive.
- SJF (shortest job first) runs the shortest job that has arrived whenever the CPU is free. When all the jobs are there at the start, it gives the lowest possible average waiting time; long jobs can starve.
- SRTF (shortest remaining time first) is SJF with preemption: a new arrival with less time left takes the CPU. The lowest average waiting time of all, at the cost of more switches.
- Round Robin gives each process a fixed time slice in turn. Good response time for everyone. A very large slice turns it into FCFS; a very small one spends the CPU on switching.
- Priority runs the highest priority first, with or without preemption. Low-priority processes can starve; aging (raising a priority the longer it waits) fixes that.
The rules this simulator follows
- On a tie, the process that arrived first goes first, then the one with the lower number.
- A preemptive algorithm never switches on a tie: the running process keeps the CPU.
- Round Robin: a process that arrives at the same moment a time slice ends joins the queue before the process that was just preempted. Most textbooks and exam keys do this; if your question says otherwise, swap those two.
- Priority: a lower number is a higher priority, as in most textbooks. Tick the box if your question says the opposite.
- Switching between processes takes no time (no context switch overhead).
Exam traps
- The CPU can sit idle. If nothing has arrived yet, the chart has a gap, and every time is still counted from 0.
- In Round Robin a process waits several times. Use WT = TAT − BT instead of adding the gaps by hand.
- SRTF and preemptive priority only change their mind when a process arrives or finishes: check the chart at each arrival.
- For a non-preemptive algorithm, response time and waiting time are the same. They differ once a process can be preempted.
More simulators: page replacement, disk scheduling and the Banker's algorithm.