Skip to content
Official PYQ · 1998

GATE CS 1998 Q2.17 — CPU Scheduling

Explain with AI

Consider nn processes sharing the CPU in a round-robin fashion. Assuming that each process switch takes ss seconds, what must be the quantum size qq such that the overhead resulting from process switching is minimized but at the same time each process is guaranteed to get its turn at the CPU at least every tt seconds?

Choose one option
View worked solution

Answer: A

To find the optimal quantum size qq, let us analyze the worst-case waiting time for any process in a round-robin system with nn processes.

1. Calculating the Maximum Waiting Time

Suppose a process P1P_1 has just finished its current CPU quantum. Before P1P_1 can get its next turn at the CPU, all other (n−1)(n-1) processes must be scheduled and run for their respective quanta.

  • Execution time of other processes: There are (n−1)(n-1) other processes, each running for at most qq seconds. Total execution time = (n−1)q(n-1)q seconds.
  • Context switch overhead: To cycle through all nn processes and return to P1P_1, there are exactly nn context switches (from P1→P2P_1 \to P_2, P2→P3P_2 \to P_3, ..., Pn→P1P_n \to P_1). Each switch takes ss seconds. Total switching overhead = nsns seconds.

Thus, the maximum time a process has to wait between the end of its current turn and the start of its next turn is:

Twait=(n−1)q+nsT_{\text{wait}} = (n-1)q + ns

2. Applying the Constraint

To guarantee that each process gets its turn at least every tt seconds, this waiting time must not exceed tt seconds:

(n−1)q+ns≤t(n-1)q + ns \le t

Solving for qq:

(n−1)q≤t−ns(n-1)q \le t - ns q≤t−nsn−1q \le \frac{t - ns}{n - 1}

3. Minimizing Overhead

To minimize the overhead caused by frequent context switching, we want the time quantum qq to be as large as possible. However, to satisfy the response time guarantee, qq must respect the upper bound derived above.

Therefore, the required condition is:

q≤t−nsn−1q \le \frac{t - ns}{n - 1}

Hence, the correct option is A.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore CPU Scheduling questions