Question

I would like to know how a program while its executing can see and use interrupts. I have read about the level, edge, hybrid, and message type of interrupts and that the device sends a pulse to signal for an interrupts, but how does a program see that interrupts? Or is the interrupt visible to the program at all? Thanks for any help with this

Was it helpful?

Solution

In general, an occurrence of an interrupt causes the processor to stop doing what it was doing, remember where it stopped and go to a special piece of code which reacts somehow to it. The hardware checks for interrupts all the time, regardless of what else the processor is doing at the moment. So it goes to the special piece of code, the so-called interrupt handler, and after it's done, it returns to what it was doing before. The interrupted program doesn't notice anything.

The address where the interrupt handler is located at depends on the processor architecture and the interrupt type. Sometimes it's required to be at a fixed point in memory, the address of which is given in the datasheet for the processor. Most often there is a special array at the fixed address in the memory called intrrupt vector table, which stores addresses of procedures which handle interrupts of different kinds.

On a PC, or any other slightly more advanced electronics, the interrupt handlers and the interrupt vector table are part of the operating system. You don't need to be bothered by interrupts at all, unless you're writing an OS or programming an embedded device.

OTHER TIPS

Depends on the OS, if any. On the general-purpose 'desktop' OS we are most familar with, user-mode programs never have to process hardware interrupts directly. The interrupts from peripherals such as keyboards, mice, disks, NIC etc. are handled by drivers. Usually, a thread in the 'program' makes a read/write request API call and the call does not return until the request is completed - this is the nearest the program gets to hardware. In the kernel, the calling thread is blocked until the addressed driver signals that the I/O requested has been completed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top