4.4.4 timer中断流向root domain(记录到interrupt log)

点击查看系列文章 =》 Interrupt Pipeline系列文章大纲-优快云博客

原创不易,需要大家多多鼓励!您的关注、点赞、收藏就是我的创作动力!

4.4.4 timer中断流向root domain(记录到interrupt log)

timer中断在head domain中的中断处理程序xnintr_core_clock_handler,在不同的时机,会把timer中断号3记录到root domain的interrupt log。在《3.4.1.3 IPIPE interrupt log数据结构》中,已经讨论过interrupt log的记录与回放。

第一,xnintr_core_clock_handler起始

第205行,判断收到中断的CPU是否属于实时调度CPU,如果不属于则执行第207行,调用ipipe_post_irq_root->__ipipe_set_irq_pending(&ipipe_root, irq),将中断号XNARCH_HOST_TICK_IRQ记录到root domain的interrupt log中。

XNARCH_HOST_TICK_IRQ的定义在哪?它实际是读取ipipe_percpu.hrtimer_irq的值。在当前的例子中,ipipe_percpu.hrtimer_irq的值是3,所以中断号3会被记录到root domain的interrupt log中。

arch/arm64/xenomai/ipipe/include/asm/xenomai/machine.h
#define XNARCH_HOST_TICK_IRQ __ipipe_hrtimer_irq

include/linux/ipipe_tickdev.h
#define __ipipe_hrtimer_irq __ipipe_raw_cpu_read(ipipe_percpu.hrtimer_irq)

 

ipipe_percpu.hrtimer_irq在什么时候初始化?如下图,在Xenomai初始化的过程中,调用ipipe_select_timers为IPIPE选择一个timer。因为此时只有一个timer,所以必然会被选中,它的virq是3,ipipe_percpu.hrtimer_irq也等于3。

第二,xnintr_core_clock_handler中部

void xnintr_core_clock_handler(void)
{
    …………
    // 减少中断嵌套计数
    if (--sched->inesting == 0) {
        // 清除标志位表示不再处理中断
        sched->lflags &= ~XNINIRQ;
        // 执行调度操作
        xnsched_run();
        // 重新获取当前调度器实例
        sched = xnsched_current();
    }
    …………
}

沿着xnsched_run->__xnsched_run->pipeline_schedule->___xnsched_run,会有2处调用xnintr_host_tick。xnintr_host_tick本质上是调用ipipe_post_irq_root。如上面分析,ipipe_post_irq_root调用__ipipe_set_irq_pending(&ipipe_root, irq),将中断号XNARCH_HOST_TICK_IRQ(3)记录到root domain的interrupt log中。

 

第三,xnintr_core_clock_handler末尾

根据注释,可知在timer中断抢占root domain线程时,需调用xnintr_host_tick(sched)向root domain传递timer中断。

void xnintr_core_clock_handler(void)
{
    …………
    /*
     * 如果核心时钟中断抢占了一个实时线程,
     * 任何从实时线程到根线程的转换已经在 xnsched_run() 中触发了主机时钟中断传播。
     * 因此,在这里只需要在中断抢占根线程时传播主机时钟中断。
     */
    if ((sched->lflags & XNHTICK) &&  // 检查是否有主机时钟中断需要传播
        xnthread_test_state(sched->curr, XNROOT))  // 检查当前运行的线程是否是根线程
        // 传播主机时钟中断
        xnintr_host_tick(sched);
}

在head domain中的中断处理程序中,在不同的时机,会把timer中断号3记录到root domain的interrupt log。在《3.4.1.3 IPIPE interrupt log数据结构》中,已经讨论过interrupt log的记录与回放。 

 

点击查看系列文章 =》 Interrupt Pipeline系列文章大纲-优快云博客

原创不易,需要大家多多鼓励!您的关注、点赞、收藏就是我的创作动力!

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值