Understanding the Linux software interrupt

Verbatim https://www.dazhuanlan.com/2019/08/25/5d625adf891d0/


Interrupt: Interrupt system is a mechanism used to respond to hardware requests, it will interrupt the normal execution and scheduling processes, and then call the kernel interrupt handling process in response to the requesting device.

Visualize the interrupt description: Take takeaway scene

1. interrupt is an asynchronous event handling mechanism, improve concurrent processing capability of the system

2. To reduce the impact on the normal processes were running, interrupt handling process needs to run as soon as possible

3. Interrupt divided into upper and lower parts

(1)上半部用来快速处理中断,在中断禁止模式下,主要处理跟硬件紧密相关的或时间敏感的工作
(2)下半部用来延迟处理上半部未完成的工作,通常以内核线程的方式运行。

summary:

  • The upper half of a direct request processing hardware, namely hardware interrupt, features fast execution
  • The lower half triggered by the kernel, that is soft interrupt, is characterized by delayed execution

In fact, the upper half of the CPU will interrupt the task being performed, and then performs terminal processing process immediately. The lower half of kernel threads execute in a manner, and each corresponds to a soft interrupt CPU kernel thread called "ksoftirq / cpu number."

In addition to the lower half of the soft interrupt hardware interrupt handling process points, including some custom kernel events, such as: the kernel dispatcher lock RCU

4.proc file system is a mechanism for kernel space and user space communication can be used to view the data structure used to dynamically modify the kernel or the kernel configuration, such as:

  • / Proc / softirqs provide soft interrupt operation
  • / Proc / interrupts to provide a hard interrupt operation

Auxiliary Case deepen understanding

Examples: NIC receive data packets

After the card receives a packet, it will by way of hardware interrupts, tells the kernel to the new data. At this time, the kernel will call the interrupt handling process to respond to it.

In this case, the upper and lower halves in charge of the work:

  • The upper half: Since it is a fast process, in fact, put the card data into memory, then update about the state of the hardware registers (indicates that data was read well), and finally sent a soft interrupt message informing the bottom half done further processed.
  • Lower half: After being soft interrupt wake up, you need to find the network data from memory, and then according to the network protocol stack, layer by layer processes the data parsing and processing until it sent the application process.

Guess you like

Origin www.cnblogs.com/petewell/p/11408856.html