28.5k views
2 votes
Consider the following set of processes, the length of the CPU burst time given in milliseconds :

Process Burst time
P1 6
P2 8
P3 7
P4 3
Assuming the above process being scheduled with the SJF scheduling algorithm, what is the wait time for P1?

User Blasio
by
7.1k points

1 Answer

7 votes

Under the Shortest Job First scheduling algorithm, the wait time for process P1 with a burst time of 6 milliseconds is 3 milliseconds, which is the burst time of the only process with a shorter burst time (P4) scheduled before it.

The Shortest Job First (SJF) scheduling algorithm selects the process with the shortest burst time to execute first. Given the burst times of the processes P1 = 6, P2 = 8, P3 = 7, and P4 = 3, the SJF will schedule them in the order of P4, P1, P3, and P2 based on their burst times. P4 will be executed first since it has the shortest burst time of 3 milliseconds.

To calculate the wait time for P1, you must sum the burst times of the processes that are scheduled before it. Since P4 is the only process with a shorter burst time than P1, the wait time for P1 is simply the burst time of P4, which is 3 milliseconds.

User Pavel Fedotov
by
7.7k points