The Gateway to Computer Science Excellence
+30 votes

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

  1. $\text{0%}$
  2. $\text{10.6%}$
  3. $\text{30.0%}$
  4. $\text{89.4%}$
in Operating System by Active
edited by | 6.4k views

7 Answers

+60 votes
Best answer

$$\text{CPU Idle time}=\frac{2+3}{47} \times 100 = 10.6383\%$$

Answer is option (B).

by Boss
edited by
Can you explain a bit? Didn't understood the diagram?

in the first time interval of $\{0-2\}$ there are 3 processes working simultaneously at I/O and at the same time CPU is idle. but in the third time interval i.e. $\{4-6\}$ process 1 is running on the CPU, Process 3 is busy doing its I/O and the process 2 is waiting in the ready queue coz it needs CPU but its occupied.

there are only 3 processes in the system, and no new processes are to come, so cpu idle time is 2+3

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

p2 has compute time 14 and p3 has compute time 11 ..and we are following shortest compute time so how can you schedule p2 first and then p3
I've rechecked; It is correct.
Do we have to consider the last I/O time as it can be allotted to any process thereafter so the only idle time for CPU must be the starting 2 unit time. (As the CPU is idle after 44 unit time)
Yes we have to consider the last I/O as the CPU does not terminate on its own. A system request is sent after the completion of the last process to terminate the execution.
So, i/o and cpu can be scheduled at a same time?
Throughput here is 3/47 right ..?
nice explanation @ amarvashistha
what if new process p4 arrives at 44 having burst time 3 units other than p1 p2 p3.

Then out of total 47 cpu will be idle for 2 units only ??

As we don't know is there any such process comng  in ready queue other than p1 p2 p3 at 44 we have to consider till 44 only

Hence % idle  =( 2/44) * 100
for i/o there is i/o processor

@jatin khachane 1

we have to calculate with that instance only.

if you didn't agree that, then i can say at t=1, there is P4 come with BT=1, then your answer also wrong.

isn't it?

Why should we consider 44-47 as CPU idle time.

It can be answered based on this ques --> What operation is going on between 44-47?? I / O

Does that employs CPU idle ??
yes, I/O means CPU idle...

Ok means we are considering only processes possible which are given in question..

yes, otherwise 0-2 also not lead to idle time of CPU
And what if the I/O operations doesn't overlaps.
+14 votes





P1 10 (10*20/100)=2 (10*70/100)=7 (10*10/100)=1
P2 20 (20*20/100)=4 (20*70/100)=14 (20*10/100)=2
P3 30 (30*20/100)=6 (30*70/100)=21 (30*10/100)=3


Idle P1 P2 P3 Idle

0                          2                     9                     23                  44                    47

total time=47

idle time= 2+3=5

% of idle time= (5/47)*100=10.6%

by Active
+7 votes

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.

 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 %
+6 votes

Option "B" 

by Loyal
+3 votes

Answer will be 10.6382

by Active
+1 vote
  $i/o$ $cpu$ $i/o$
1 2 7 1
2 4 14 2
3 6 21 3


Assume that all I/O operations can be overlapped as much as possible.


$\underbrace{0-2}$ $\underbrace{2-9}$ $\underbrace{9-23}$ $\underbrace{23-44}$ $\underbrace{44-47}$
$idle$ $p1$ $p2$ $p3$ $idle$

$\dfrac{5}{47}\times 100=10.6\%$

by Loyal
0 votes

Total time needed to complete the execution = 47
Idle time = 2+3 = 5
Percentage of Idle time = 5/47 × 100 =10.6%

by Active
why cpu remains idle for 44-47

is it waiting for p3 to get executed?

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
52,215 questions
60,009 answers
94,695 users