Seventh, interruption and interruption processing
7.1 Interrupts
Interrupts allow the hardware to be notified to the processor. Interrupts can be generated at any time, and the kernel can be interrupted at any time due to new interruptions.
Different devices correspond to different interrupts, and each interrupt passes through a unique digital flag. The operating system provides a corresponding interrupt handler for different interrupts.
These interrupt values are often referred to as interrupt request (IRQ) lines, and each IRQ line is associated with a quantity value.
Abnormal:
When the processor executes an error instruction (such as 0) that is caused by a programming mistake, or if there is a special case (such as a missing pages) during execution, it must be
When the kernel is processed, the processor generates an exception.
7.2 Interrupt Handlers
In response to a specific interrupt, the kernel executes a function called an interrupt handler.
In Linux, an interrupt handler is an ordinary C function.
The real difference between interrupt handlers and other kernel functions is that interrupt handlers are tuned by the kernel to respond to interrupts, and they run on what we call interrupts
In the context of a particular context.
Interrupts can occur at any time, so an interrupt handler can be executed at any time.
At the very least. The interrupt handler is responsible for notifying the hardware device that the interrupt has been received.
7.3 Comparison of the upper and lower halves of the top half
and want to interrupt the processing program to run fast, and want to interrupt the process of the completion of a lot of work, these two purposes are clearly inconsistent. In view of the existence of this elimination between the two purposes
Contradictory, so we generally cut the interrupt processing into two parts or two halves. Interrupt processing is the top half (receiving an interrupt, it starts executing immediately, but only does have strict
Work), Linux provides a variety of mechanisms for implementing the bottom half.
7.4 Registering an interrupt handler
If the device uses interrupts, the responding driver registers an interrupt handler.
The driver can register an interrupt handler through the REQUEST--IRQ function and activate the given medium break to handle interrupts:
/*REQUEST_IRQ: Assigns a given interrupt line */
int REQUEST_IRQ (unsigned int IRQ,
irq_handler_t Handler,
unsigned long flags,
const Char *name,
void *dev)
The first parameter IRQ indicates the interrupt number to be assigned;
The second parameter, handler, is a pointer to the actual interrupt handler that handles the interrupt.
Interrupt Handler Flags:
See book P94
To release the interrupt handler:
When uninstalling the driver, you need to unregister the appropriate interrupt handler and release the disconnection:
Void FREE_IRQ (unsigned int irq,void *dev)
7.5 Writing interrupt handlers
"Linux kernel Design and implementation" chapter seventh reading notes