Consider the following three processes with the arrival time and CPU burst…

2018

Consider the following three processes with the arrival time and CPU burst time given in milliseconds :

The Gantt Chart for preemptive SJF scheduling algorithm is _________.

Attempted by 488 students.

Show answer & explanation

Key idea: use preemptive shortest remaining time first (SRTF). At each arrival check if the new process has a smaller remaining burst; if so, preempt the running process.

  • Given processes: P1 (arrival 0, burst 7), P2 (arrival 1, burst 4), P3 (arrival 2, burst 8).

  • Step-by-step scheduling:

    • Time 0–1: Only P1 has arrived, so P1 runs for 1 unit (remaining for P1 = 6).

    • At time 1 P2 arrives with burst 4 which is less than P1's remaining 6, so P1 is preempted and P2 runs from time 1 to 5 (P2 completes).

    • After P2 finishes at time 5, choose the shortest remaining among P1 (6) and P3 (8). P1 is shorter, so P1 resumes from time 5 to 11 (P1 completes).

    • Finally P3 runs from time 11 to 19 and completes.

  • Final Gantt chart (time intervals):

    • 0 – 1 : P1

    • 1 – 5 : P2

    • 5 – 11 : P1

    • 11 – 19 : P3

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor