23.4k views
0 votes
consider three process (p1, p2, p3), all arriving at time zero, with total execution time of 10, 20 and 30 units respectively. each process spends the first 20% of execution time doing i/o, the next 70% of time doing computation, and the last 10% of time doing i/o again. the operating system uses a shortest remaining compute time first scheduling algorithm and schedules a new process either when the running process gets blocked on i/o or when the running process finishes its compute burst. assume that all i/o operations can be overlapped as much as possible. compute the completion time of process p2.

1 Answer

5 votes

the completion time of process p2 is 20 units

To determine the completion time of process p2, let's analyze the execution timeline for all three processes:

Process | Total Execution Time | I/O Time (20%) | Computation Time (70%) | I/O Time (10%)

P1 | 10 units | 2 units | 7 units | 1 unit

P2 | 20 units | 4 units | 14 units | 2 units

P3 | 30 units | 6 units | 21 units | 3 units

P2 starts its computation burst, and P1 continues its computation burst simultaneously. After 7 units, P1 completes its computation burst and enters its final I/O burst. P2 continues its computation burst until it reaches the 14-unit mark, at which point it also enters its final I/O burst.

While P1 and P2 are doing I/O, P3 arrives and enters its first I/O burst. Once P1 and P2 complete their I/O bursts, they become eligible for execution again. P3 completes its first I/O burst and begins its computation burst.

P2's computation burst is shorter than P1's, so it finishes first and enters its final I/O burst. P1 continues its computation burst until it finishes, and P3 continues its computation and final I/O bursts.

all three processes complete their execution.

The completion time of process p2 can be calculated by adding up its I/O and computation times:

Completion time of P2 = I/O time (20%) + Computation time (70%) + I/O time (10%)

Completion time of P2 = 4 units + 14 units + 2 units

Completion time of P2 = 20 units

Therefore, the completion time of process p2 is 20 units.

User Mwangi
by
7.2k points