1.7k 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.

edited | 1.7k views

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 \%}$

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

0
+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%

0
Why are we taking main prog execution time =1000us??
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%
by Veteran (60.2k points)
edited
+5
so the % of the time cpu devoted to the main program should be
1ms/(1+0.1)ms
=90.9%
0
Interrupt input arrives EVERY 1ms, i.e, within 1 ms not after 1ms.

So 90% is correct.
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%
by Active (2.3k points)
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
by (75 points)

1
2