linux顶半部和底半部中断机制
来源:互联网 发布:淘宝省钱app 编辑:程序博客网 时间:2024/06/14 22:01
-
-
- void xxx_do_tasklet(unsigned long);
- DECLARE_TASKLET(xxx_tasklet,xxx_do_tasklet,0);
-
- void xxx_do_tasklet(unsigned long)
- {
- ............
- }
-
- irqreturn_t xxx_interrupt(int irq,void *dev_id,struct pt_regs *regs)
- {
- .....................
-
- tasklet_schedule(&xxx_tasklet);
- ......................
- }
-
- int __init xxx_init(void)
- {
- .................
-
- result=request_irq(xxx_irq,xxx_interrupt,SA_INTERRUPT,"XX",NULL);
- ..................
- }
-
- void __exit xxx_exit(void)
- {
- .....................
- free_irq(xxx_irq,xxx_interrupt);
- .....................
- }
-
-
-
- struct work_struct xxx_wq;
- void xxx_do_work(unsigned long);
-
- void xxx_do_work(unsigned long)
- {
- ....................
- }
-
- irqreturn_t xxx_interrupt(int irq,void *dev_id,struct pt_regs *regs)
- {
- ................
- schedule_work(&xxx_wq);
- ...................
- }
-
- int xxx_init(void)
- {
- ................
-
- result=request_irq(xxx_irq,xxx_interrupt,SA_INTERRUPT,"xxx",NULL);
- .................
-
- INIT_WORK(&xxx_wq,(void (*)(void *)) xxx_do_work,NULL);
- .................
- }
-
- void xxx_exit(void)
- {
- ...............
-
- free_irq(xxx_irq,xxx_interrupt);
- ................
- }
-
-
-