Terms: Burst time (CPU time needed), Arrival time, Completion time, Turnaround time = Completion − Arrival, Waiting time = Turnaround − Burst, Response time = first run − arrival.
| Algorithm | Type | Idea | Problem |
|---|---|---|---|
| FCFS | Non-preemptive | First come, first served | Convoy effect (short jobs wait behind a long one) |
| SJF | Non-preemptive | Shortest burst first; minimum average waiting time | Starvation of long jobs; burst time must be known |
| SRTF | Preemptive SJF | Shortest remaining time first | Starvation |
| Priority | Either | Highest priority first | Starvation → fixed by aging |
| Round Robin | Preemptive | Each process gets a time quantum in turn | Too small quantum = many context switches |
| Multilevel Queue | Either | Separate queues (system, interactive, batch) | Rigid |
Round Robin example with its waiting and turnaround times
// FCFS waiting time: each process waits for all bursts before it
int burst[] = {24, 3, 3}, n = 3, wait = 0, total = 0;
for (int i = 0; i < n; i++) {
total += wait;
wait += burst[i];
}
cout << "Average waiting = " << (double)total / n; // (0 + 24 + 27) / 3 = 17