Interrupt exception

Here Insert Picture Description

Category 1

Interrupts generally divided into synchronous and asynchronous interrupt interrupts:

Synchronization is interrupted when the instruction is executedCPUControl unit produced, is called synchronous, because the CPU will be issued only after executing one instruction interrupt termination.
The ◎Synchronization InterruptCalledAbnormal (exception)

Asynchronous interrupt byOther hardware devicesIn accordance with the CPU clock signal generated randomly.
The ◎Asynchronous interruptCalledInterrupt (interrupt)

Category 2

(1) hardware interrupt

Automatically generated by the peripheral (such as cards, hard disk) is connected to the system. The main change is used to inform the state of the operating system peripherals. For example, when the network adapter receives a packet, it will send out an interrupt. We usually refer to interrupt refers to the hardware interrupt (hardirq).

(2) soft interrupt

In order to meet the requirements of real-time systems, interrupt handling should be the sooner the better. linux To achieve this feature, when an interrupt occurs, the hardware interrupt processing that short period of time to complete the work, but will deal with those events long work interruption into the later completion, which is soft interrupt (softirq) to complete .

(Note: that is, bottom-half)

Hard and soft interrupt interrupted difference

  • Soft interrupt is generated interrupt instruction execution, and peripheral hardware interrupt is triggered.

  • Hardware interrupt interrupt number is provided by the interrupt controller, interrupt soft interrupt number indicated by direct instruction, without the use of an interrupt controller.

  • Hardware interrupt is masked, soft non-masked interrupt.

  • Hardware interrupt handler to ensure that it can complete the task quickly, so that when the program is executed without waiting for a long time, called the upper half.

  • Hard interrupt soft interrupt handling unfinished work, mechanisms for the implementation of the latter is pushed, belong to the lower half.

  • Under Linux hardware interrupt can be nested, but there is no concept of priority, which means that any new interrupt can interrupt the interrupt is being executed, but the same kind of interrupt exception. Soft interrupt can not be nested, but the same type of soft interrupt can be executed in parallel on a different CPU.

Interrupt controller operation

Each hardware interrupt request can be issued has such an output device controller, called the IRQ line. IRQ input lines are all available to this interrupt controller (PIC) connected to pins of a hardware circuit. Let's look at this the interrupt controller performs the following actions:

    1)    监视IRQ线,检查产生的信号 。如果有一条或两条以上的IRQ线上产生信号,就选择引脚编号较小的IRQ线。

    2)    如果一个引发信号出现在IRQ线上:

            a)    把接收到的引发信号转换成对应的向量(索引)。

            b)    把这个向量存放在中断控器的一个I/O端口,从而允许CPU通过数据总线读取此向量。

            c)    把引发信号发送到处理器的INTR引脚,即产生一个中断。

            d)    等待,直到CPU通过把这个中断信号写进可编程中断控制器的一个I/O端口来确认它;当这种情况发生时,清INTR线。

    3)    返回到第一步。

Achieve technological break is two-fold:

    1)    汇编语言代码:与处理器高度相关,用于处理特定平台上相关的底层细节;

    2)    抽象接口:是设备驱动程序及其他内核代码安装和管理IRQ处理程序所需的。
Published 452 original articles · won praise 271 · views 730 000 +

Guess you like

Origin blog.csdn.net/qq_35608277/article/details/105081596