Registering Interrupts

The mechanisms discussed above are effective only for interrupts raised by an interrupt request from a system peripheral. But the kernel must also take care of interrupts raised either by the processor itself or by software mechanisms in an executing user process. In contrast to IRQs, the kernel need not provide an interface for this kind of interrupt in order to dynamically register handlers. This is because the numbers used are made known at initialization time and do not change thereafter. Registering of interrupts, exceptions, and traps is performed at kernel initialization time, and their reservations do not change at run time.

The platform-specific kernel sources have very few commonalities, not surprising in view of the sometimes large technical differences. Even though the concepts behind some variants may be similar, their concrete implementation differs strongly from platform to platform. This is because implementation must walk a fine line between C and assembly language code in order to do justice to the specific features of a system.

The greatest similarity between the various platforms is a filename. arch/arch/kernel/traps.c contains the system-specific implementation for registering interrupt handlers.

The outcome of all implementations is that a handler function is invoked automatically when an interrupt occurs. Because interrupt sharing is not supported for system interrupts, all that need be done is to establish a link between the interrupt number and function pointer.

Generally, the kernel responds to interrupts in one of two ways.

□ A signal is sent to the current user process to inform it that an error has occurred. On IA-32 and AMD64 systems, for example, a division by 0 is signaled by interrupt 0. The automatically invoked assembly language routine divide_error sends the sigpfe signal to the user process.

□ The kernel corrects the error situation invisibly to the user process. This is the case on, for example, IA-32 systems, where interrupt 14 is used to signal a page fault, which the kernel can then correct by employing the methods described in Chapter 18.

Continue reading here: Servicing IRQs

Was this article helpful?

0 0