Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Suppose that in responding to interrupts from an I/O device the processor consum

ID: 3820206 • Letter: S

Question

Suppose that in responding to interrupts from an I/O device the processor consumes 1000 cycles in performing the context switch required to transfer control to the interrupt handler. Servicing the device request takes an additional 10,000 cycles whether using interrupts or polling. Once the interrupt processing is complete, another 1000 cycles are required to perform the context switch required to return from the interrupt handler and resume the program that was running. The device generates I/O requests at the rate of 150 per second (each request causes an interrupt).

a) How many cycles per second does the processor spend handling interrupts and processing requests from the device?

b) Consider an alternative to using interrupts in which a program polls the device for requests every 0.5ms. If this program is the only code running on the processor and each poll requires 500 cycles, how many cycles per second will the program spend on polling alone?



c) At what rate would the program have to poll the I/O device if the program is to consume the same number of cycles per second polling and servicing requests as were consumed using interrupts and servicing requests (as calculated in part a)?

Explanation / Answer

a) The device generates 150 I/O requests per second, each of which takes 10,000 + 2x1000 (context switching to the interrupt handler and back from it) = 12,000 cycles.

Thus, a total of 150 x 12,000=1,800,000 cycles per second are spent handling I/O using interrupts.

b) There are 150 interrupt requests per second, or one interrupt request every 0.5ms.

Every interrupt consumes a total of 12,000 cycles, as calculated in part (a).

For a 500 MHz CPU, this is 12000 / (500 x 10^6) = 24 microseconds.

For 150 interrupts per second, this is 3.6 msec.

This allows 1000 – 3.6 = 996.4msec for polling.

Since the processor polls once every 0.5msec during the time when there is no interrupt, this corresponds to 996/0.5 = 1992 times per second.

The total number of cycles required for polling is 1992 x 500 = 996,000 cycles per second.

Thus, the total time spent on I/O when using polling with interrupts is 1,800,000 + 996,000 = 2,796,000 cycles per second.

c) The interrupt overhead is 1000 cycles per second for a context switch to the Interrupt request and 1000 cycles per second back from it.

This is a total of 2 x 1000 cycles per second. With 150 interrupts per second, this is 150 x 2000 = 300,000 cycles per second.

The polling overhead is 500 cycles per second. Thus, for the same overhead as interrupts, the polling operation should be performed 300,000 / 500 = 600 times per second, or 1/600 = every 1.66 msec.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote