Search code examples
interruptpolling

How can polling be faster than interupt


I'm trying to learn interrupts by reading these slides and am wondering, why can polling be faster than interrupts? If a device has a direct wire to the CPU that it can use to signal an interrupt, I can't imagine something being faster than that.

Give each device a wire (interrupt line) that it can use to signal the processor • When interrupt signaled, processor executes a routine called an interrupt handler to deal with the interrupt

(does it litterally mean a wire by the way?)

Polling can be better if processor has to respond to an event ASAP


Solution

  • Interrupt handling, needs context switching (pipeline break, save stack pointer, CPU registers, etc..) before servicing the interrupt, which needs some time (dependent on the architecture). Polling can be faster if it's the only task (keep polling for the event), as you stay in the same context. In this case, it's only the poll + loop instructions time.