# GATE1993-6.8

2.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.

edited

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
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??
2

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.

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
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.
0

@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?

0
yes, absolutely!
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%
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

## Related questions

1
5.3k views
The root directory of a disk should be placed at a fixed address in main memory at a fixed location on the disk anywhere on the disk at a fixed location on the system disk anywhere on the system disk
A certain moving arm disk storage, with one head, has the following specifications: Number of tracks/recording surface $= 200$ Disk rotation speed $= 2400$ rpm Track storage capacity $= 62,500$ bits The average latency of this device is $P$ ms and the data transfer rate is $Q$ bits/sec. Write the values of $P$ and $Q$.
Write a concurrent program using $\text{parbegin-parend}$ and semaphores to represent the precedence constraints of the statements $S_1$ to $S_6$, as shown in figure below.
The following page addresses, in the given sequence, were generated by a program: $\text{1 2 3 4 1 3 5 2 1 5 4 3 2 3}$ This program is run on a demand paged virtual memory system, with main memory size equal to $4$ pages. Indicate the page references for which page faults occur for the following page replacement algorithms. LRU FIFO Assume that the main memory is initially empty