The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+13 votes
1.3k views

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.6k points)
edited by | 1.3k views

4 Answers

+12 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
0
@bikram sir, Is the answer 90% as in the best answer or 90.9%?
+3
Yes, correct answer is 90 %
+4

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

0
@hs_yadav why 900 microseconds ?
+2
@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 ?
0
yes , we would consider cycle time (repeated sequence i.e..1000us).....

but you have taken the time before first interrupt....
0
@Surabhi,

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.
0
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 % = (10 + 80 +10)*10^(-6)/1*10^(-3)   *100
                                               = 10%
% of time CPU devoted to main program = 90%
answered by Veteran (55.6k points)
+4
interrupt overhead is 0.1ms
so the % of the time cpu devoted to the main program should be
1ms/(1+0.1)ms
=90.9%
+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.5k 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)
Answer:

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

42,599 questions
48,601 answers
155,674 comments
63,742 users