📄 softirq.c.txt
字号:
any problems,send email to netxiong@263.net
原来版本的do_bottom_half已经被废止了。取而代之的事do_soft_irq,数据结构也随之改变了
*********************进本数据结构******************************
(1):irq_cpustat_t irq_stat[NR_CPUS]
定义了相当于do_bottom_half中的active_bh和mask_bh的结构,但是提供了多处理机的机制。
实际上就是相当于每一个cpu设置了一个active_bh和mask_bh组和其他的一些相应字段。
(2):static struct softirq_action softirq_vec[32]
这个结构相对于irq_stat,每一个向量存储一个指向一个带有处理函数指针的结构。(interrupt.h)
和原来系统的bh_base功能一样,更具有可扩展型。
(3):static void (*bh_base[32])(void);
(4):struct tasklet_struct bh_task_vec[32];
这两个结构死行影相随的。linux的设计者使用了一种新的结构对原来的bottom half进行了重新的改造。
bh_base中依然存放相应的处理函数,
在bh_task_vec中的每一个向量中都放了一个结构
(4):struct tasklet_head tasklet_vec[NR_CPUS] __cacheline_aligned;
这个结构是每一个cpu对应的tasklet队列。
(5):truct tasklet_head tasklet_hi_vec[NR_CPUS]
这个结构是每一个cpu对应的tasklet_hi队列。
*************************************************************************
***********************softirq基本函数*****************************
(1):asmlinkage void do_softirq()
#检验是否处于中断状态,如果正在中断,退出
#local_irq_disable(),__cli,关中断。
#然后检查softirq_active和softirq_mask。
#如果有设置为1的位数,
#先将active位复位。
#循环将这些位为1的相应的处理函数取出进行运行。
#在退出循环之前在检查一遍,如果有又active位被设置为1,重新进行处理.
(2):void __init softirq_init()
这个函数在init/main.c中的start_kernel中调用。
主要是对softirq进行初始化。
首先对旧的bh_task_vec进行初始化。
for (i=0; i<32; i++)
tasklet_init(bh_task_vec+i, bh_action, i);
通过bh_action来联系bh_action
open_softirq(TASKLET_SOFTIRQ, tasklet_action, NULL);
open_softirq(HI_SOFTIRQ, tasklet_hi_action, NULL);
然后调用open_softirq对TASKLET_SOFTIRQ和HI_SOFTIRQ进行初始化。
(3):void open_softirq(int nr, void (*action)(struct softirq_action*), void *data)
对softirq_vec[nr].action = action
然后对相应得mask进行初始化。
*************************************************************************
**************************tasklet函数************************************
(1):static void tasklet_action(struct softirq_action *a)
#list = tasklet_vec[cpu].list //将指定的cpu上的tasklet队列取下来
#tasklet_vec[cpu].list = NULL; //然后把他置惟空。
#然后进入循环,一次读去链表中的元素,取出其中的处理函数进行处理。
#然后将取出来的元素在一次连接到tasklet_vec[cpu].list中去。(?)
#对这个cpu的TASKLET_SOFTIRQ位进行置位。
(2):static void tasklet_hi_action(struct softirq_action *a)
它的结构和tasklet_action基本一样,
##对这个cpu的HI_SOFTIRQ位进行置位。
(3):void tasklet_init(struct tasklet_struct *t,
void (*func)(unsigned long), unsigned long data)
对bh_task_vec进行初始化
t->func = func;
t->data = data;
************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -