critical section 中断唤醒系统流程(6)

电脑杂谈  发布时间:2018-02-14 08:19:48  来源:网络整理

4)resume_irqs继续调用,最终会enable所有在susoend中关闭的irq。

5)check_irq_resend才是真正触发你注册的中断handle执行的真凶。

check_irq_resend代码如下:

void check_irq_resend(struct irq_desc *desc)

{

/*

* We do not resend level type interrupts. Level type

* interrupts are resent by hardware when they are still

* active. Clear the pending bit so suspend/resume does not

* get confused.

*/

if (irq_settings_is_level(desc)) {

desc->istate &= ~IRQS_PENDING;

return;

}

if (desc->istate & IRQS_REPLAY)

return;

if (desc->istate & IRQS_PENDING) {

desc->istate &= ~IRQS_PENDING;

desc->istate |= IRQS_REPLAY;

if (!desc->irq_data.chip->irq_retrigger ||

!desc->irq_data.chip->irq_retrigger(&desc->irq_data)) {

unsigned int irq = irq_desc_get_irq(desc);

/* Set it pending and activate the softirq: */

set_bit(irq, irqs_resend);

tasklet_schedule(&resend_tasklet);

}

}

}

由于在之前分析已经设置了IRQS_PENDING flag,因此这里会tasklet_schedule(&resend_tasklet)并且置位irqs_resend变量中相应的bit位,代表软中断触发。然后就开始tasklet_schedule最终会唤醒ksoftirqd线程,在ksoftirqd线程中会调用你注册的中断handle,毕竟ksoftirqd线程优先级很高,所以很快就会调度了。具体调用过程可以参考wowo的softirq和tasklet文章。这里我们也可以得出中断handle执行的上下文环境是软中断上下文的结论。当然我们还是有必要分析一下tasklet最后一步resend_irqs()函数的作用,代码如下:

/* Bitmap to handle software resend of interrupts: */

static DECLARE_BITMAP(irqs_resend, IRQ_BITMAP_BITS);

/*

* Run software resends of IRQ‘s

*/

static void resend_irqs(unsigned long arg)

{

struct irq_desc *desc;

int irq;

while (!bitmap_empty(irqs_resend, nr_irqs)) {

irq = find_first_bit(irqs_resend, nr_irqs);


本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-77055-6.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...