Skip to content
Official PYQ · 2006

GATE CS 2006 Q65 — CPU Scheduling

Explain with AI

Consider three processes, all arriving at time zero, with total execution time of 1010, 2020 and 3030 units, respectively. Each process spends the first 20%\text{20\%} of execution time doing I/O, the next 70%\text{70\%} of time doing computation, and the last 10%\text{10\%} of time doing I/O again. The operating system uses a shortest remaining compute time first scheduling algorithm and schedules a new process either when the running process gets blocked on I/O or when the running process finishes its compute burst. Assume that all I/O operations can be overlapped as much as possible. For what percentage of time does the CPU remain idle?

Choose one option
View worked solution

Answer: B

First, we break down the execution phases for each process based on their total execution times:

  • P1P_1 (10 units):
    • First I/O: 10×20%=210 \times 20\% = 2 units
    • CPU computation: 10×70%=710 \times 70\% = 7 units
    • Second I/O: 10×10%=110 \times 10\% = 1 unit
  • P2P_2 (20 units):
    • First I/O: 20×20%=420 \times 20\% = 4 units
    • CPU computation: 20×70%=1420 \times 70\% = 14 units
    • Second I/O: 20×10%=220 \times 10\% = 2 units
  • P3P_3 (30 units):
    • First I/O: 30×20%=630 \times 20\% = 6 units
    • CPU computation: 30×70%=2130 \times 70\% = 21 units
    • Second I/O: 30×10%=330 \times 10\% = 3 units

Now, we trace the scheduling timeline using the Shortest Remaining Compute Time First (SRCTF) algorithm:

  • t=0t = 0 to t=2t = 2: All three processes are performing their first I/O. The CPU remains idle (2 units).
  • At t=2t = 2: P1P_1 completes its first I/O and starts its CPU computation (remaining compute = 7).
  • At t=4t = 4: P2P_2 completes its first I/O (remaining compute = 14). Since P1P_1 has a shorter remaining compute time (5<145 < 14), P1P_1 continues.
  • At t=6t = 6: P3P_3 completes its first I/O (remaining compute = 21). P1P_1 continues.
  • At t=9t = 9: P1P_1 finishes its CPU computation and starts its second I/O (finishes at t=10t = 10). P2P_2 is scheduled next as its remaining compute time (14) is less than P3P_3's (21).
  • At t=23t = 23: P2P_2 finishes its CPU computation and starts its second I/O (finishes at t=25t = 25). P3P_3 is scheduled.
  • At t=44t = 44: P3P_3 finishes its CPU computation and starts its second I/O.
  • t=44t = 44 to t=47t = 47: P3P_3 performs its second I/O. The CPU remains idle (3 units).
  • At t=47t = 47: All processes have completely finished.

Calculations:

  • Total time of the system = 4747 units
  • Total CPU idle time = 2 (at start)+3 (at end)=52 \text{ (at start)} + 3 \text{ (at end)} = 5 units
  • Percentage of CPU idle time = 547×100%≈10.64%\frac{5}{47} \times 100\% \approx 10.64\%

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

Published
Report a correction
Keep exploringMore CPU Scheduling questions