Question:

Consider a single processor system with four processes A, B, C, and D, represented as given below, where for each process the first value is its arrival time, and the second value is its CPU burst time. \[ A (0, 10), \, B (2, 6), \, C (4, 3), \, D (6, 7). \] Which one of the following options gives the average waiting times when preemptive Shortest Remaining Time First (SRTF) and Non-Preemptive Shortest Job First (NP-SJF) CPU scheduling algorithms are applied to the processes?

Show Hint

When solving CPU scheduling problems, use tables to calculate Completion Time, Turnaround Time, and Waiting Time for each process. Apply the appropriate algorithm rules, such as preemption in SRTF and non-preemption in NP-SJF.
Updated On: Jan 23, 2025
  • SRTF = 6, NP-SJF = 7
  • SRTF = 6, NP-SJF = 7.5
  • SRTF = 7, NP-SJF = 7.5
  • SRTF = 7, NP-SJF = 8.5
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

Non-Preemptive SJF Scheduling: \[ \begin{array}{|c|c|c|c|c|c|} \hline Process & Arrival Time & Burst Time & Completion Time & Turnaround Time & Waiting Time
\hline A & 0 & 10 & 10 & 10 & 0
B & 2 & 6 & 19 & 17 & 11
C & 4 & 3 & 13 & 9 & 6
D & 6 & 7 & 26 & 20 & 13
\hline \end{array} \] The total average waiting time for NP-SJF is: \[ \text{Average Waiting Time} = \frac{0 + 11 + 6 + 13}{4} = \frac{30}{4} = 7.5. \] Preemptive SRTF Scheduling: \[ \begin{array}{|c|c|c|c|c|c|} \hline Process & Arrival Time & Burst Time & Completion Time & Turnaround Time & Waiting Time
\hline A & 0 & 10 & 26 & 26 & 16
B & 2 & 6 & 11 & 9 & 3
C & 4 & 3 & 7 & 3 & 0
D & 6 & 7 & 18 & 12 & 5
\hline \end{array} \] The total average waiting time for SRTF is: \[ \text{Average Waiting Time} = \frac{16 + 3 + 0 + 5}{4} = \frac{24}{4} = 6. \] Note: Turnaround Time is calculated as: \(\text{Completion Time} - \text{Arrival Time}\). Waiting Time is calculated as: \(\text{Turnaround Time} - \text{Burst Time}\). Final Answer: \[ \boxed{\text{(2) SRTF = 6, NP-SJF = 7.5}} \]
Was this answer helpful?
0
0

Top Questions on Lexical analysis

View More Questions

Questions Asked in GATE CS exam

View More Questions