in Operating System recategorized by
4,814 views
26 votes
26 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.

in Operating System recategorized by
4.8k views

4 Answers

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

edited by

4 Comments

Why are we taking main prog execution time =1000us??
1
1

We are not taking main program execution time = 1000 us

we are taking ratio i.e.  if main program executes for 1000 us then interrupt executes for 100us

The above equation is derived from the fact " For every 1 ms an interrupt occurs which is served for 100 microseconds "

we are making it 1000 since both the units are different in above line. ms = millisecond , us = microsecond.

3
3
Why this 10 microsecond of arrival of interrupt input not included? What does this 10 microseconds signfy?
0
0
20 votes
20 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%
edited by

4 Comments

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%
5
5
Interrupt input arrives EVERY 1ms, i.e, within 1 ms not after 1ms.

So 90% is correct.
1
1

@Kaurbaljit

we are basically taking 1 cycle=starting of 1 interrupt to starting of the other interrupt=1000us

and within this 100us are used for the interrupt and remaining 900us used for the program.

so efficient time/cycle time=900/1000=90%

 

Is this correct?

1
1
yes, absolutely!
0
0
4 votes
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%
0 votes
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
Answer:

Related questions