All Exams Test series for 1 year @ ₹349 only
Question

Consider the following 3 processes with the length of the CPU burst time given in milliseconds :

ProcessArrival TimeBurst Time
P108
P214
P329

What is the average waiting time for these processes if they are scheduled using preemptive shortest job first scheduling algorithm?

The correct answer is

4.67

Step By Step Solution :

Consider the following processes with their Arrival Time (AT) and Burst Time (BT):

ProcessArrival Time (ms)Burst Time (ms)
P108
P214
P329

Scheduling Algorithm Used: Preemptive Shortest Job First (SJF) (also known as Shortest Remaining Time First – SRTF)

 

Step 1: Scheduling Order

Time 0 – 1: Only P1 is available, so P1 starts execution. Remaining time of P1 = 7 ms

Time 1: P2 arrives with burst time 4 ms, which is less than P1’s remaining time. So, P1 is preempted and P2 starts execution.

Time 1 – 5: P2 continues execution and completes at time 5.

Time 5: P1 (7 ms remaining) and P3 (9 ms) are available. P1 has the shortest remaining time, so P1 executes.

Time 5 – 12: P1 completes execution at time 12.

Time 12 – 21: Only P3 remains, so P3 executes and completes at time 21.

 

Step 2: Completion Time (CT)

ProcessCompletion Time (CT)
P112
P25
P321

 

Step 3: Waiting Time Calculation

Formula used:

Waiting Time (WT) = Completion Time − Arrival Time − Burst Time

  • P1 = 12 − 0 − 8 = 4 ms
  • P2 = 5 − 1 − 4 = 0 ms
  • P3 = 21 − 2 − 9 = 10 ms

 

Step 4: Average Waiting Time

Average Waiting Time =

(4 + 0 + 10) / 3 = 14 / 3 = 4.67 ms

The average waiting time using preemptive SJF scheduling is 4.67 milliseconds.

Was this answer helpful?

Important Questions from Process Scheduling - Teaching

  1. Consider the following four processes with the arrival time and length of CPU burst given in milliseconds :

    ProcessArrival TimeBurst Time
    P 108
    P 214
    P 329
    P 435

    The average waiting time for preemptive SJF scheduling algorithm is

  2. Which of the following is not a CPU scheduling Algorithm?

  3. Which of the following statement(s) is/are true about CPU scheduling algorithm?

    I. Shortest remaining time first scheduling may cause starvation

    II. Round Robin is better than First Come First Serve in terms of response time

  4. A process residing in main memory and ready and waiting for execution, is kept on

  5. In which of the following scheduling criteria, context switching will never take place?

Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App