AlgoFrames

Compute waiting time

Warm-up · Predict the result · about 3 min

Non-preemptive SJF ran three processes and produced the Gantt chart below.

| Process | Arrival | Burst | |---|---|---| | P1 | 0 | 7 | | P2 | 2 | 4 | | P3 | 4 | 1 |

What is the average waiting time?

Example 1

Input:

{"processes":[{"name":"P1","arrival":0,"burst":7},{"name":"P2","arrival":2,"burst":4},{"name":"P3","arrival":4,"burst":1}]}

Output:

?

Constraints

  • Answer with a number.
  • Waiting time = finish − arrival − burst.

Learn the idea first: CPU scheduling: FCFS, SJF, priority, round robin, a visual lesson.

More CPU scheduling: FCFS, SJF, priority, round robin problems