The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+15 votes

The details of an interrupt cycle are shown in figure.

Given that an interrupt input arrives every $1$ msec, what is the percentage  of the  total time that the CPU devotes for the main program execution.

asked in Operating System by Veteran (59.8k points)
edited by | 1.4k views

4 Answers

+13 votes
Best answer

Time to service an interrupt $=$ saving of cpu state $+$ ISR execution $+$ restoring of CPU state $=( 80+10+10) \times 10^{-6}=\mathbf{100}$ microseconds

For every $1$ ms an interrupt occurs which is served for $100$ microseconds
1 ms $\to$ 1000 microseconds.

After every $1000$ microseconds of main code execution, $100$ microseconds for interrupt overhead exists.

Thus, for every $1000$ microseconds, $(1000 - 100 ) = 900$ microseconds of main program and $100$ microseconds of interrupt overhead exists.

Thus, $900/1000$ is usage of CPU to execute main program 

% of CPU time used to execute main program is $\mathbf{(900 /1000) \times 100 =90.00 \%}$

answered by Active (1.1k points)
edited by
@bikram sir, Is the answer 90% as in the best answer or 90.9%?
Yes, correct answer is 90 %

if answer is 90.9%.....then ...what is wrong with this....please:

@hs_yadav why 900 microseconds ?
@bikram sir , I think my answer is wrong . Image posted. By hs_yadav is right .

Input occurs every 1000 microseconds .

i have considered 1000 units from the time of competition of  execution of 1st interrupt .

But 1000 units must be considered from the time of arrival of 1st interrupt


hence it has to be 900/1000*100 =90%

right sir ?
yes , we would consider cycle time (repeated sequence i.e..1000us).....

but you have taken the time before first interrupt....

But when the interrupt arrives, CPU doesn't stop it's execution and it continues for 10 us and next 100 us for (context switch from main to interrupted process+ processing the interrupted process + context switch from interrupted process to main.)

So out of 1msec=1000us , main for 900us and interrupt(conetxt switch+process+context switch)=100.

%main program=(900/1000)*100%=90%

Your first answer is correct.
Why are we taking main prog execution time =1000us??
+12 votes
CPU overhead will be saving context + serving interrupt + restoration.
out of 1ms, these things are overhead for CPU.
OVERHEAD % $= \frac {(10 + 80 +10) * 10^{-6}}{1*10^{-3}   *100} = 10 \%$
% of time CPU devoted to main program = 90%
answered by Veteran (55.9k points)
edited by
interrupt overhead is 0.1ms
so the % of the time cpu devoted to the main program should be
+4 votes
Here we see before first interrupt is come main program started execution then interrupt is come include over head of(10+80+10) = 100usec. Then program again start execution until second interrupt is acknowledge. So out of 1000usec of total exection of process both main program and interrupt process there is 100usec overhead for interrupt.

So % of Overhead = (100/1000)*100 = 10%

So % of main program execution = 90%
answered by Active (2.6k points)
0 votes
Lets Assume for 1 second of cpu time,  

cpu time = main program execution + time to service some no of Interrupts

we know in 1 sec there are 10^3 msec, so there are 10^3 interrupts arriving in 1 sec and from diagram we know

1 interrupt takes = 10 usec(saving of cpu state)+80 usec(ISR execution)+10 usec(Restoration of cpu state)

so total 1 interrupt takes 100 usec which is 10^-4 sec

so time to service 10^3 interrupt takes 10^3 * 10^-4 = 10^-1 sec

so Main program execution=cpu time - time to service 10^3 interrupts

Main program exec=1-0.1 = 0.9 sec

which is 90% of cpu time for this assumption
answered by (75 points)

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

46,787 questions
51,234 answers
66,585 users