Consider the following table of arrival time and burst time for three…

2020

Consider the following table of arrival time and burst time for three processes P₀, P₁, P₂.

image.png

The preemptive shortest job first scheduling algorithm is used. Scheduling is carried out only at arrival or completion of process. The average waiting time for the three process is ______.

  1. A.

    7 seconds

  2. B.

    4.8 seconds

  3. C.

    6 seconds

  4. D.

    5 seconds

Attempted by 144 students.

Show answer & explanation

Correct answer: D

To solve this Preemptive Shortest Job First (SRTF) problem, we track the execution step-by-step using a Gantt chart based on the processes' remaining burst times:

  • At t = 0: Only P0 arrives (Remaining Burst Time, RBT = 9). It executes.

  • At t = 1: P1 arrives (RBT = 4). Since P1's burst time (4) is shorter than P0's remaining time (8), P0 is preempted. P1 runs until completion at t = 5 (since no other shorter job arrives at t=2, where P2 arrives with RBT = 9).

  • At t = 5: Ready processes are P0 (RBT = 8) and P2 (RBT = 9). P0 executes next from t = 5 to t = 13.

  • At t = 13: Finally, P2 executes from t = 13 to t = 22.

Waiting Time (WT = Turnaround Time - Burst Time):

  • P0: (13 - 0) - 9 = 4 seconds

  • P1: (5 - 1) - 4 = 0 seconds

  • P2: (22 - 2) - 9 = 11 seconds

Average Waiting Time ={4 + 0 + 11}/3 = 15/3 = 5 seconds

Thus, the correct option is D.

Explore the full course: Niacl Ao It Specialist