Skip to content
Related Articles
Open in App
Not now

Related Articles

GATE | GATE-CS-2006 | Question 65

Improve Article
Save Article
Like Article
  • Difficulty Level : Medium
  • Last Updated : 14 Feb, 2018
Improve Article
Save Article
Like Article

Consider three processes, all arriving at time zero, with total execution time of 10, 20 and 30 units, respectively. Each process spends the first 20% of execution time doing I/O, the next 70% of time doing computation, and the last 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?

(A) 0%
(B) 10.6%
(C) 30.0%
(D) 89.4%


Answer: (B)

Explanation:

Shortest remaining time ( SRT ) scheduling algorithm selects the process for execution which has the smallest amount of time remaining until completion.

Let three processes be p0, p1 and p2. Their execution time is 10, 20 and 30 respectively.

p0 spends first 2 time units in I/O, 7 units of CPU time and finally 1 unit in I/O.
p1 spends first 4 units in I/O, 14 units of CPU time and finally 2 units in I/O.
p2 spends first 6 units in I/O, 21 units of CPU time and finally 3 units in I/O.

PIDATIOBTIO
P00271
P104142
P206213

AT- Arrival Time, IO-input/output, BT-Burst Time

first process p0 will spend 2 units in IO, next 7 units in BT, then process p1 will spend 14 units in BT (as its 4 units of IO has been spent already when previous process was running) and ten process p2 will spend 21 units in BT (as its 6 units of IO has been spent already when previous processes were running) and atlast 3 units in IO (process p0,p1,p2’s last IO included.)

idle   p0    p1     p2    idle
0    2     9     23     44     47

Total time spent = 47
Idle time = 2 + 3 = 5
Percentage of idle time = (5/47)*100 = 10.6 %

See Question 2 of https://www.geeksforgeeks.org/operating-systems-set-15/

This solution is contributed by Nitika Bansal

Quiz of this Question

My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!