Foreword:
Hello everyone, today we will continue to share the learning summary in the Linux kernel. Today we will talk about the interrupt mechanism in the Linux kernel; we should be very familiar with the interrupt, so I will not introduce its concept here. ha!
1. Linux interrupt workflow:
When explaining the Linux interrupt workflow, let's take a look at the general interrupt workflow first. When you are familiar with the general interrupt workflow, then the Linux interrupt workflow is almost clear!
Interrupt workflow:
1. Conversion of cpu working mode
2. Copy and push the register
3. Set the interrupt exception vector table
4. Save the return value of the function that is running normally
5. Jump to the corresponding interrupt service function to run
6. Perform mode restoration and register restoration
7. Jump back to the normal working function address to continue running
Next, let's look at the Linux interrupt workflow:
1. Push all register values onto the stack
2. Push the exception code onto the stack
3. Push the return value of the current function onto the stack (in order to find where the interrupt was interrupted after the execution is interrupted, and it can be restored!)
4. Call the corresponding interrupt service function
5. The return value of the stack function
6. Return all push register values
For better understanding, the above can be summarized as:
(1) Processing before interruption
(2) Interrupt execution process
(3) Interrupted recovery process
The following is the Linux interrupt work flow chart:
Ok, now that we have such a general framework, we can start to analyze the code of the interrupt part. The code structure of the interrupt part is mainly divided into two parts:
Part of it is the processing of hardware interrupts:
Processing of software interrupts and system calls:
The specific code corresponding to the figure is as follows:
The interrupt code is mainly in the Kernel directory:
2. Summary:
Ok, I will briefly share it here today. Since some assembly code is involved here, we will share the source code analysis part in the next issue. Today, it is enough to master the Linux interrupt workflow and the code structure distribution in the Linux kernel!
Article related references:
Linux kernel 0.11 fully commented
https://www.bilibili.com/video/BV1tQ4y1d7mo?spm_id_from=333.337.search-card.all.click
By the way, the personal circle of friends has been opened, and the pits are limited. I often share some non-technical things. If you are interested, you can come and chat and make friends; technical aspects are also available. Everyone learns from each other and makes progress together: Threesome , there must be my teacher!