What is interruption? What is an exception?

Source: Internet
Author: User

The Linux kernel needs to manage all the hardware devices connected to the computer, which is undoubtedly part of it. To manage these devices, you must first communicate with them. Generally, there are two solutions to achieve this function:
1. Polling allows the kernel to regularly query the device status and then process the status accordingly;
2. Interrupt enables the hardware to send signals to the kernel as needed (switch the kernel to the hardware actively ).
The first solution will make the kernel do a lot of useless work, because Round Robin will always be executed cyclically repeatedly, consuming a lot of CPU time, so the efficiency is low, so the second solution is generally used.

What is interruption?

From the perspective of physics, interruption is an electrical signal generated by hardware devices and directly sent to the input pin of the interrupt controller (such as 8259a, then the interrupt controller sends the corresponding signal to the processor.Once the processor detects this signal, it will interrupt the work it is currently processing and then process the interruption. After that, the processor will notify the OS that an interruption has occurred. In this way, the OS can properly handle this interrupt.
Different devices have different interruptions, and each interruption is identified by a unique number. These values are generally called the interrupt request line (IRQ ).

An interrupt can be divided into synchronous interrupt and asynchronous interrupt:
1. Synchronization interruption occurs when the command is executed by the CPU control unit. It is called synchronization because the CPU is interrupted only after a command is executed, insteadCodeDuring command execution, such as system calls.
2. asynchronous interruption refers to the random generation by other hardware devices according to the CPU clock signal, that is, the interruption can occur between commands, such as keyboard interruption.

What is an exception?

Synchronous interrupt is also called exception, while asynchronous interrupt is called interrupt ). In general, the disconnection refers to asynchronous interruption.
1. interruption can be divided into Maskable Interrupt and nomaskable interrupt ).
2. Exceptions can be divided into fault, trap, and abort.

For the similarities and differences between these categories, see table 1.

Table 1: interrupt categories and Behaviors

CATEGORY reason asynchronous/Synchronous return Behavior
The signal from the I/O device is interrupted and always returned to the next command asynchronously.
The intentionally abnormal synchronization in the trap always returns to the next command.
Potential fault-recoverable errors are returned to the current command synchronously
Unrecoverable error synchronization will not be returned

What is Interrupt Processing?Program?

In response to a specific interrupt, the kernel executes a function called the interrupt handler or interrupt service routine.Each device that generates an interrupt has a corresponding interrupt handler. If a device can produce multiple different interruptions, the device can correspond to multiple interrupt handlers. The interrupt handler of a device is part of its device driver.

What is the upper half and lower half of the interrupt?

Interrupt Processing is generally divided into two parts. The interrupt processing program is in the upper half: it is executed immediately after an interruption is received, but only works with a strict time limit, these tasks are completed when all interruptions are disabled. The work that can be completed later is postponed to the lower half. Generally, the lower half is executed immediately when the interrupt handler returns.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.