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. Consider the following set of processes and the length of CPU burst time given in milliseconds:

    Process

    CPU Burst time (ms)

    P 1

    5

    P 2

    7

    P 3

    6

    P 4

    4

    Assume that processes being scheduled with Round-Robin Scheduling Algorithm with Time Quantum 4ms. Then the waiting time for P 4is _________ ms.

  3. Consider three intensive processes, which requires 10,20 and 30 units of time and arrive at times 0,2 and 6 respectively. how many context switches are needed if the operating system implements a shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end.

  4. Which of the following CPU scheduling algorithms is/are supported by LINUX operating system?

  5. Given CPU time slice of 2 ms and the following list of processes.

    Process

    Burst time (ms)

    Arrival time (ms)

    p 1

    3

    0

    p 2

    4

    2

    p 3

    5

    5

    Find average turnaround time and average waiting time using round-robin CPU scheduling?
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