CS Atlas GATE 2027
COA course
0 / 87 complete

COA/Phase 6 · I/O: Interrupts & DMA

Lesson 6.2.2 · Item 77 of 87

Interrupt-driven I/O: overhead per transfer; interrupts vs polling

Read at your own pace. Try the questions before opening the answers.

On this page

0 · Recall Warm-up

Answer from memory first. Answers are in the Answer Vault at the bottom.

  • What return address is saved when an interrupt arrives during an instruction? from Lesson 6.2.1
  • Polling CPU fraction for r polls/s, p cycles each, clock f? from Lesson 6.1.2
  • Daisy-chain priority is decided by? from Lesson 6.2.1

1 · The Hook

🎣

Interrupts are not free: every one costs a context save, a jump, the ISR and a return, often hundreds of cycles. For a slow device they save almost all the CPU's time; for a very fast device they can cost more than polling would. GATE's favourite version: "how many times better is interrupt mode than program-controlled mode?"

2 · Predict First

🤔

A device delivers one byte every 100 µs. In program-controlled (busy-wait) mode the CPU is tied up the whole 100 µs per byte. In interrupt mode it spends 4 µs per byte on interrupt overhead. How many times less CPU time does interrupt mode use?

Make a guess in your head. The answer opens Section 3.

3 · Core Concept

💡

Predict First — the answer

100 / 4 = 25 times.

CPU time with interrupts

For each transfer unit (byte, word or small block) the CPU spends the interrupt overhead c (save, ISR, return).

Fraction of CPU time = (units per second) × c (with c in seconds) = units/s × cycles per interrupt ÷ f.

Example: disk at 4 MB/s in 16-byte units, 500 cycles per interrupt, 500 MHz: 250,000 × 500 / 5×10⁸ = 25% while the disk is transferring. If the disk transfers only 10% of the time: 2.5% overall. (Polling would have to keep polling all the time.)

Interrupt mode vs program-controlled mode

  • Program-controlled (busy-wait): the CPU is occupied for the whole time between units, T_unit = 1 ÷ (units per second).
  • Interrupt mode: occupied only for the overhead c per unit.

Gain = T_unit / c.

Example: 40 KB/s (decimal), byte-wise: T_unit = 25 µs; overhead 2 µs → gain 12.5.

When interrupts lose

If the device is so fast that units arrive about as often as the overhead c, interrupts eat nearly all the CPU and can be worse than tight polling. For high-speed block devices, DMA (next lesson) is used: one interrupt per block, not per word.

4 · Visual

Program-controlled (busy-wait), one byte every 25 us:
CPU: |##########################|##########################|   busy all the time

Interrupt mode, 2 us overhead per byte:
CPU: |##|.......free...........|##|.......free...........|    busy 2 of every 25 us

5 · Worked Examples

Example 1 Easy

1,000 interrupts per second, 2,000 cycles each, 1 GHz CPU. Fraction of CPU time?

Solution

2×10⁶ / 10⁹ = 0.2%.

Example 2 Medium

A device transfers 10 KB/s (decimal) byte by byte; interrupt overhead is 5 µs per byte. Fraction of CPU time in interrupt mode?

Solution

10,000 × 5 µs = 50 ms per second = 5%.

Example 3 GATE

A device with data rate 16 KB/s (decimal) transfers byte-wise. Interrupt overhead is 2.5 µs. The byte transfer between interface and memory is negligible. What is the minimum performance gain of interrupt mode over program-controlled mode?

Solution

T_unit = 1/16000 s = 62.5 µs; gain = 62.5 / 2.5 = 25.

6 · GATE Traps

⚠️

  • Gain = time between units ÷ overhead per unit.
  • Convert data rate to units per second with the right unit size (byte, word, block).
  • I/O rates: decimal unless stated.
  • Interrupt overhead counts per unit transferred, every time.

7 · Memory Hook

🧠

"Busy-wait pays the gap; interrupts pay the overhead." Gain = gap ÷ overhead.

8 · Connect the Dots

Interrupts cut the cost per unit; DMA cuts the number of units the CPU handles: one setup and one interrupt per block. Last lesson of the subject's main content: DMA and the CPU time it takes away.

9 · Self-Test

GATE format. Try every question before opening the vault.

Q1NAT2 marksGain

A device transfers 20 KB/s (decimal) byte-wise; interrupt overhead 5 µs. Gain of interrupt mode over program-controlled mode?

Numerical answer: ________

Q2NAT2 marksFraction

A 2 GHz CPU handles 100,000 interrupts per second at 3,000 cycles each. Percentage of CPU time?

Numerical answer: ________

Q3NAT2 marksFraction with idle time

A disk delivers 8 MB/s (decimal) in 32-byte units while active; each interrupt costs 400 cycles on a 1 GHz CPU. The disk is active 20% of the time. Overall percentage of CPU time spent on its interrupts?

Numerical answer: ________

Q4MCQ1 markVery fast devices

For a device that produces a word every few hundred nanoseconds in long bursts, the best transfer method is usually:

  • (A) software polling inside an ISR
  • (B) one interrupt per word
  • (C) DMA
  • (D) programmed I/O with polling

Q5NAT1 markBusy time

In interrupt mode with 4 µs overhead per byte, how many ms of CPU time does transferring 5,000 bytes cost?

Numerical answer: ________

10 · Rule Card

  • Interrupt CPU fraction = units/s × overhead per unit (cycles/f).
  • Gain over busy-wait = time between units ÷ overhead.
  • Scale by the device's active fraction for overall cost.
  • Very fast block devices → DMA.

11 · Concept Ledger

Unlocked in this lesson. From here on, these terms may be used.

interrupt overhead per transferinterrupt CPU fractiongain over program-controlled I/Odevice active fraction

12 · Answer Vault

Answer Vault

Try the questions first. Open when you are ready to check.

Recall Warm-up

  • The address of the next instruction.
  • r·p / f.
  • Position on the acknowledge line.

Self-Test

Q1 Answer: 102 marks

T_unit = 50 µs; 50 / 5.

Re-read: Lesson 6.2.2 — Interrupt-driven I/O: overhead per transfer; interrupts vs polling

Q2 Answer: 152 marks

3×10⁸ / 2×10⁹.

Re-read: Lesson 6.2.2 — Interrupt-driven I/O: overhead per transfer; interrupts vs polling

Q3 Answer: 22 marks

250,000 units/s × 400 = 10⁸ cycles/s = 10% while active; × 0.2 = 2%.

Re-read: Lesson 6.2.2 — Interrupt-driven I/O: overhead per transfer; interrupts vs polling

Q4 Answer: (C)1 mark

Per-word interrupts would swamp the CPU.

  • (A) is wrong: Still per-word CPU work.
  • (B) is wrong: Overhead per word is too large.
  • (D) is wrong: Ties up the CPU completely.

Re-read: Lesson 6.2.2 — Interrupt-driven I/O: overhead per transfer; interrupts vs polling

Q5 Answer: 201 mark

5000 × 4 µs.

Re-read: Lesson 6.2.2 — Interrupt-driven I/O: overhead per transfer; interrupts vs polling

Ready for the next idea?

Mark this item complete when you’ve finished reading and working through it.