Linux interrupt Summary

Source: Internet
Author: User

Linux interruptions include hard interruptions and soft interruptions.

Hardware interruption is triggered by hardware devices. When a hard interrupt occurs on an I/O device, the interrupt controller sends an electrical signal, which is received by the driver of the kernel, the corresponding interrupt handler is called to process the interrupt. A hard interrupt can come at any time. It represents an emergency task that must be handled immediately by the system, or the upper half of the interrupt, which corresponds to the lower half of the interrupt (buttom half ), it is also called Soft Interrupt, which means that the system does not have to handle less urgent tasks immediately.

A soft interrupt handler is generally called at the end of a hard interrupt handler. The hard interrupt is in the so-called "interrupt context ". This corresponds to the "process context ". The following explains the process context. Each user process can be divided into user and kernel states. Generally, the process runs in the user State. When a process calls a system call function, it enters the kernel state, at this time, the process is in the "process context" in the kernel state. Of course, the kernel thread also belongs to the process context, such as the ksoftirqd thread. Therefore, the kernel state has two kinds of contexts: one is the interrupt context and the other is the process context ". Interrupt context is generally used for applications with low real-time requirements and high execution frequency.

The special feature is Soft Interrupt. Soft Interrupt is executed when it is returned after the interrupt processing is complete, which is in the interrupt context. In earlier kernel versions, there were no ksoftirqd kernel threads to prevent repeated calls of soft interruptions. At this time, soft interruptions will always run in the "interrupt context ". In later kernel versions, in order to prevent the execution of soft interruptions from being triggered all the time, other processes may take too long, when the number of executions reaches a maximum value, the kernel thread ksoftirqd is executed, and then the result is returned after the interruption. instead of being interrupted. execute Soft Interrupt in the kernel thread ksoftirqd, which is in the context of the process. In this case, soft interruptions may occur in the "interrupt context" or "process context ".

An interrupt has its own priority to respond to different processing requests. The Soft Interrupt priority is relatively low, and can be interrupted by hard interrupt, but not by the user's code. While

Hard interruptions cannot be interrupted by other interruptions.

Reference the differences between the interrupt context and process context in the Linux kernel architecture:

(1) interrupts are executed asynchronously and can occur at any time.

(2) The Scheduler cannot be called in the interrupt context, so the Scheduler cannot automatically give up control.

(3) The interrupt handler cannot enter sleep state. The reason is that the interrupt context cannot be interrupted. After the process goes to sleep, the kernel can only wait forever.

This is the current understanding of Linux interruptions, and there may be deviations. Let's fix it slowly.

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.