How is ISR a callback function

RootPhoenix picture RootPhoenix · Aug 2, 2014 · Viewed 7.1k times · Source

The wikipedia entry states:

In computer system programming, an interrupt handler, also known as an interrupt service routine or ISR, is a callback function in microcontroller firmware, an operating system or a device driver, whose execution is triggered by the reception of an interrupt.

How is ISR a callback. Is it the PC value stored on stack itself is the callback function?

I.e., the ISR calls the interrupted function back. Hence the interrupted function is a callback.

Answer

Boann picture Boann · Aug 2, 2014

A bit of setup code stores the address of the ISR function in the interrupt vector table to say "call me back at this address when the interrupt occurs".

To be clear, the ISR itself is the function that is "called back". The interrupted code is not the callback; it is merely "interrupted" and later "resumed".