FCFS: order P1 (0 to 5), P2 (5 to 8), P3 (8 to 9). Waiting times are 0, 4 and 6, so the average is 10/3, about 3.33. Average turnaround is (5 + 7 + 7)/3, about 6.33.
Non-preemptive SJF: P1 runs 0 to 5; then P3 (5 to 6) and P2 (6 to 9). Waiting times are P1 0, P3 3, P2 5, so the average is 8/3, about 2.67.
SRTF: P1 runs 0 to 1, P2 preempts it (1 to 2), P3 preempts P2 (2 to 3), then P2 finishes (3 to 5) and P1 finishes (5 to 9). Waiting times are P1 4, P2 1, P3 0, so the average is 5/3, about 1.67 (the best of the four).
Round robin with quantum 2 (new arrivals queue before the preempted process): completion times are P1 9, P2 8, P3 5, giving waiting times 4, 4 and 2, so the average is 10/3, about 3.33.
Method: waiting time = completion time - arrival time - burst time. Always state your tie-breaking assumptions.
Loading…