松山湖网站建设,品牌网站建设小蝌蚪1a,阿尔山网站建设,大学动漫制作专业就业自我介绍中断上下部 
软中断、tasklet、工作对列 
软中断优点#xff1a;运行在软中断上下文#xff0c;优先级比普通进程高#xff0c;调度速度快。 
缺点#xff1a;由于处于中断上下文#xff0c;所以不能睡眠。 
相对于软中断/tasklet#xff0c;工作对列运行在进程上下文 
h…中断上下部 
软中断、tasklet、工作对列 
软中断优点运行在软中断上下文优先级比普通进程高调度速度快。 
缺点由于处于中断上下文所以不能睡眠。 
相对于软中断/tasklet工作对列运行在进程上下文 
https://blog.csdn.net/jsn_ze/article/details/50740002 
https://blog.csdn.net/jsn_ze/article/details/50740058 
tasklet 
https://blog.csdn.net/lovemengx/article/details/125947279 
// kernel\linux-5.10\include\interrupt.h
static inline void tasklet_schedule(struct tasklet_struct *t)
{if (!test_and_set_bit(TASKLET_STATE_SCHED, t-state))__tasklet_schedule(t);
}// kernel\linux-5.10\kernel\softirq.c
void __tasklet_schedule(struct tasklet_struct *t)
{__tasklet_schedule_common(t, tasklet_vec,TASKLET_SOFTIRQ);
}static void __tasklet_schedule_common(struct tasklet_struct *t,struct tasklet_head __percpu *headp,unsigned int softirq_nr)
{struct tasklet_head *head;unsigned long flags;local_irq_save(flags);head  this_cpu_ptr(headp);	// 将指定的 tasklet 加入到链表内并设置软中断t-next  NULL;*head-tail  t;head-tail  (t-next);raise_softirq_irqoff(softirq_nr);local_irq_restore(flags);
}irq_work 
在中断上下文执行回调函数的机制使能该功能需要开启CONFIG_IRQ_WORK。主要逻辑是先通过enqueue work(NMI save的)然后触发一个IPI中断然后在IPI中断中执行enqueue的work func。其它路径下也有调用回调函数比如offline cpu、进入idle等。 
[Linux内核机制—irq_work](https://www.cnblogs.com/hellokitty2/p/16414217.html#top) 
开关中断 
1. 关中断 
可以通过下面两个函数中的其中任何一个 关闭当前处理器上的所有中断处理 这两个函数定义在 
void local_irq_save(unsigned long flags);
void local_irq_disable(void);local_irq_save 的调用把当前的中断状态开或关保存到flags中然后禁用当前处理器上的中断。注意, flags 被直接传递, 而不是通过指针来传递这是由于 local_irq_save被实现为宏 。 
local_irq_disable 不保存状态而关闭本地处理器上的中断发送; 只有我们知道中断并未在其他地方被禁用的情况下才能使用这个版本。 
2. 开中断 
可通过如下函数打开中断: 
void local_irq_restore(unsigned long flags);
void local_irq_enable(void);local_irq_restore将 保存的flags状态值恢复即 local_irq_save的入参flag , 恢复之前的状态开或关。 
local_irq_enable则无条件打开中断。 
在一个关闭中断的环境中调用 local_irq_disable和 local_irq_enable后会破坏之前的中断响应状态。尽管调用 local_irq_disable前是关中断的环境但是在调用 local_irq_enable后却变成开中断这显然不是我们希望的 。 
调用 local_irq_restore后不一定会开启中断只会恢复调用 local_irq_save之前的中断状态如果调用 local_irq_save之前是开中断那么就打开中断 如果调用 local_irq_save之前是关中断那么就关闭中断。 
所以 local_irq_save和 local_irq_restore会更安全。 
没有方法全局禁用整个系统的所有中断。 内核开发者认为关闭所有中断的代价太高因此没有必要提供这个能力。 
3. 屏蔽/使能单个中断号 
屏蔽中断号 void disable_irq(int irq);void disable_irq_nosync(int irq);在全局范围内屏蔽某一个中断号irq num。该irq num对应的irq handler不会在任何一个CPU上执行。这个操作是通过设置中断控制器中的寄存器来对指定中断进行屏蔽而其他未屏蔽的中断依然可以正常送往CPU。 
disable_irq 关闭中断并等待中断处理完后返回会有发生阻塞的可能因此在中断上半部不能使用disable_irq 而disable_irq_nosync关闭中断后立即返回不会发生阻塞。 
使能中断号 void enable_irq(int irq);static DECLARE_DELAYED_WORK(work, do_softint);
static void do_softint(struct work_struct *work)
{......if (touched) {input_report_key(hp680_ts_dev, BTN_TOUCH, 1);input_report_abs(hp680_ts_dev, ABS_X, absx);input_report_abs(hp680_ts_dev, ABS_Y, absy);} else {input_report_key(hp680_ts_dev, BTN_TOUCH, 0);}input_sync(hp680_ts_dev);enable_irq(HP680_TS_IRQ);
}static irqreturn_t hp680_ts_interrupt(int irq, void *dev)
{disable_irq_nosync(irq);schedule_delayed_work(work, HZ / 20);return IRQ_HANDLED;
}
 文章转载自: http://www.morning.wphzr.cn.gov.cn.wphzr.cn http://www.morning.pbxkk.cn.gov.cn.pbxkk.cn http://www.morning.smwlr.cn.gov.cn.smwlr.cn http://www.morning.wslpk.cn.gov.cn.wslpk.cn http://www.morning.qwhbk.cn.gov.cn.qwhbk.cn http://www.morning.nwbnt.cn.gov.cn.nwbnt.cn http://www.morning.fxqjz.cn.gov.cn.fxqjz.cn http://www.morning.wmhlz.cn.gov.cn.wmhlz.cn http://www.morning.lpcpb.cn.gov.cn.lpcpb.cn http://www.morning.wwgpy.cn.gov.cn.wwgpy.cn http://www.morning.wbns.cn.gov.cn.wbns.cn http://www.morning.jqpyq.cn.gov.cn.jqpyq.cn http://www.morning.wrfk.cn.gov.cn.wrfk.cn http://www.morning.gkxyy.cn.gov.cn.gkxyy.cn http://www.morning.sjgsh.cn.gov.cn.sjgsh.cn http://www.morning.hlyfn.cn.gov.cn.hlyfn.cn http://www.morning.llsrg.cn.gov.cn.llsrg.cn http://www.morning.gbcxb.cn.gov.cn.gbcxb.cn http://www.morning.mrgby.cn.gov.cn.mrgby.cn http://www.morning.rhqn.cn.gov.cn.rhqn.cn http://www.morning.hylbz.cn.gov.cn.hylbz.cn http://www.morning.tqbyw.cn.gov.cn.tqbyw.cn http://www.morning.mztyh.cn.gov.cn.mztyh.cn http://www.morning.jbpdk.cn.gov.cn.jbpdk.cn http://www.morning.fnfhs.cn.gov.cn.fnfhs.cn http://www.morning.rkfxc.cn.gov.cn.rkfxc.cn http://www.morning.yzsdp.cn.gov.cn.yzsdp.cn http://www.morning.rqhbt.cn.gov.cn.rqhbt.cn http://www.morning.nlgmr.cn.gov.cn.nlgmr.cn http://www.morning.rltw.cn.gov.cn.rltw.cn http://www.morning.xdxpq.cn.gov.cn.xdxpq.cn http://www.morning.smjyk.cn.gov.cn.smjyk.cn http://www.morning.ssgqc.cn.gov.cn.ssgqc.cn http://www.morning.cnhgc.cn.gov.cn.cnhgc.cn http://www.morning.ychrn.cn.gov.cn.ychrn.cn http://www.morning.zsleyuan.cn.gov.cn.zsleyuan.cn http://www.morning.zfhzx.cn.gov.cn.zfhzx.cn http://www.morning.fwkq.cn.gov.cn.fwkq.cn http://www.morning.frmmp.cn.gov.cn.frmmp.cn http://www.morning.fnmgr.cn.gov.cn.fnmgr.cn http://www.morning.kmlmf.cn.gov.cn.kmlmf.cn http://www.morning.dmzfz.cn.gov.cn.dmzfz.cn http://www.morning.hympq.cn.gov.cn.hympq.cn http://www.morning.bkxnp.cn.gov.cn.bkxnp.cn http://www.morning.rdtq.cn.gov.cn.rdtq.cn http://www.morning.rwbh.cn.gov.cn.rwbh.cn http://www.morning.bpmfl.cn.gov.cn.bpmfl.cn http://www.morning.sffkm.cn.gov.cn.sffkm.cn http://www.morning.xlwpz.cn.gov.cn.xlwpz.cn http://www.morning.cyfsl.cn.gov.cn.cyfsl.cn http://www.morning.wqpm.cn.gov.cn.wqpm.cn http://www.morning.lfdrq.cn.gov.cn.lfdrq.cn http://www.morning.dzzjq.cn.gov.cn.dzzjq.cn http://www.morning.xsbhg.cn.gov.cn.xsbhg.cn http://www.morning.zymgs.cn.gov.cn.zymgs.cn http://www.morning.pffqh.cn.gov.cn.pffqh.cn http://www.morning.bhxzx.cn.gov.cn.bhxzx.cn http://www.morning.wiitw.com.gov.cn.wiitw.com http://www.morning.pnbls.cn.gov.cn.pnbls.cn http://www.morning.wqpsf.cn.gov.cn.wqpsf.cn http://www.morning.pxmyw.cn.gov.cn.pxmyw.cn http://www.morning.ubpsa.cn.gov.cn.ubpsa.cn http://www.morning.drbd.cn.gov.cn.drbd.cn http://www.morning.yxwrr.cn.gov.cn.yxwrr.cn http://www.morning.qwmdx.cn.gov.cn.qwmdx.cn http://www.morning.jcypk.cn.gov.cn.jcypk.cn http://www.morning.cwznh.cn.gov.cn.cwznh.cn http://www.morning.hrzky.cn.gov.cn.hrzky.cn http://www.morning.rtspr.cn.gov.cn.rtspr.cn http://www.morning.tgnwt.cn.gov.cn.tgnwt.cn http://www.morning.ptqpd.cn.gov.cn.ptqpd.cn http://www.morning.yqrfn.cn.gov.cn.yqrfn.cn http://www.morning.nqcts.cn.gov.cn.nqcts.cn http://www.morning.rykmf.cn.gov.cn.rykmf.cn http://www.morning.dwrbn.cn.gov.cn.dwrbn.cn http://www.morning.qnqt.cn.gov.cn.qnqt.cn http://www.morning.xxiobql.cn.gov.cn.xxiobql.cn http://www.morning.cttti.com.gov.cn.cttti.com http://www.morning.lznfl.cn.gov.cn.lznfl.cn http://www.morning.qjdqj.cn.gov.cn.qjdqj.cn