軟中斷處理流程 目錄軟中斷處理流程軟中斷處理的時機中斷退出時軟中斷調度機制 軟中斷處理的時機 標準linux內核關搶占的情況下,軟中斷只在下麵兩個時機調度 中斷退出時(中斷上下文) 軟中斷線程處理 中斷退出時軟中斷調度機制 判斷是否屬於中斷上下文以及是否有軟中斷處與pending狀態 判斷軟中斷線程 ...
軟中斷處理流程
目錄軟中斷處理的時機
標準linux內核關搶占的情況下,軟中斷只在下麵兩個時機調度
- 中斷退出時(中斷上下文)
- 軟中斷線程處理
中斷退出時軟中斷調度機制
- 判斷是否屬於中斷上下文以及是否有軟中斷處與pending狀態
- 判斷軟中斷線程是否處於runing狀態(4.9內核引入)
- 進行軟中斷處理
- 最多restart 10次或者累計運行2ms
- 判斷是否還有軟中斷處於pending狀態
//kernel/softirq.c
#define MAX_SOFTIRQ_TIME msecs_to_jiffies(2)
#define MAX_SOFTIRQ_RESTART 10
void irq_exit(void)
{
... ...
if (!in_interrupt() && local_softirq_pending()) //如果不在中斷上下文並且軟中斷處於pending狀態
invoke_softirq();
... ...
}
static inline void invoke_softirq(void)
{
... ...
__do_softirq(); //執行軟中斷處理
... ...
}
asmlinkage __visible void __do_softirq(void)
{
unsigned long end = jiffies + MAX_SOFTIRQ_TIME; //__do_softirq最大運行時間2ms
int max_restart = MAX_SOFTIRQ_RESTART; //最大軟中斷處理次數
... ...
restart:
local_irq_enable(); //使能中斷,使能後軟中斷可以被硬中斷搶占
... ...
h->action(h); //執行軟中斷處理函數
... ...
local_irq_disable(); //禁用中斷
... ...
pending = local_softirq_pending();
if (pending) {
if (time_before(jiffies, end) && !need_resched() &&
--max_restart) //如果軟中斷處理次數或處理時間未達到
goto restart;
wakeup_softirqd(); //喚醒軟中斷線程進行軟中斷處理
... ...
}
本文來自博客園,作者:StepForwards,轉載請註明原文鏈接:https://www.cnblogs.com/forwards/p/18168307