Machine-translated by Google. Questions are authored in English.
Top

Discussion

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), and 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?

  • A.SRTF = 6, NP-SJF = 7
  • B.SRTF = 6, NP-SJF = 7.5
  • C.SRTF = 7, NP-SJF = 7.5
  • D.SRTF = 7, NP-SJF = 8.5

Answer: B

The average waiting times are SRTF = 6, NP-SJF = 7.5.

SRTF. A runs 0-2. B arrives with 6 against A's remaining 8 and runs 2-4. C arrives with 3 against B's remaining 4 and runs 4-7 (D, arriving at 6 with 7, does not preempt C's remaining 1). Then B runs 7-11, D 11-18 and A 18-26. Waiting time is finish minus arrival minus burst: A 16, B 3, C 0, D 5, total 24, average 6.

NP-SJF. A runs 0-10 without interruption. At 10, C (3) is shortest and runs 10-13, then B (6) 13-19, then D (7) 19-26. Waiting times: A 0, C 6, B 11, D 13, total 30, average 7.5.

The other options get one of the two schedules wrong: 7 for SRTF, or 7 and 8.5 for NP-SJF, do not match these timelines.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.