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

Discussion

Consider four processes P, Q, R, and S scheduled on a CPU as per round robin algorithm with a time quantum of 4 units. The processes arrive in the order P, Q, R, S, all at time t = 0. There is exactly one context switch from S to Q, exactly one context switch from R to Q, and exactly two context switches from Q to R. There is no context switch from S to P. Switching to a ready process after the termination of another process is also considered a context switch. Which one of the following is NOT possible as CPU burst time (in time units) of these processes?

  • A.P = 4, Q = 10, R = 6, S = 2
  • B.P = 2, Q = 9, R = 5, S = 1
  • C.P = 4, Q = 12, R = 5, S = 4
  • D.P = 3, Q = 7, R = 7, S = 3

Answer: D

The burst times that are NOT possible are P = 3, Q = 7, R = 7, S = 3.

With a quantum of 4 and the order P, Q, R, S, these bursts run as P (3, done), Q (4, 3 left), R (4, 3 left), S (3, done), Q (3, done), R (3, done). The switches are P to Q, Q to R, R to S, S to Q and Q to R, so there is no switch from R to Q at all, against the 'exactly one' required.

Each of the other sets meets every condition. For P = 4, Q = 10, R = 6, S = 2 the run is P, Q, R, S, Q, R, Q, giving one S to Q, one R to Q, two Q to R and no S to P. P = 2, Q = 9, R = 5, S = 1 runs in the same order (P, Q, R, S, Q, R, Q), and so does P = 4, Q = 12, R = 5, S = 4, where R finishes its last unit before Q's final quantum. In each, Q still needs CPU time after R's second turn, which is what produces the single R to Q switch.

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

Post your comment

Please log in or register to post a comment.