ISR计划了tasklet之后,它究竟何时运行? [英] Exactly when tasklet runs after it is schedule by ISR?

查看:61
本文介绍了ISR计划了tasklet之后,它究竟何时运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了我的ISR,我的tasklet立即运行了. 但是,我见过很多人说tasklet仅在引起CPU注意时才运行.这是一个非常通用的术语,称为 CPU注意事项,因此我对那些响应者表示敬意.我的意思是确切地说,cpu在哪一刻将注意力转移到tasklet的执行上,以及CPU的状态如何?

I written my ISR and my tasklet ran immediately. BUT, I have seen people saying that tasklet runs only when it gets CPU attention. This is a very generic term CPU attention so i recite for those responders. I mean exactly which moment cpu attention goes to tasklet execution and what happen to the state of CPU ?

其次,如果假设我一直在遭受硬中断,那么tasklet何时有机会运行? Tasklet是否可能没有机会运行?内核如何照顾这些事情?

Secondly, if suppose that i am keep on getting hard interrupt then when will tasklet get chance to run? Is it possible that tasklet may not get chance to run? How does kernel take care these things ?

推荐答案

TL; DR:任务集由调度程序处理的 ksoftirq 线程运行.

TL;DR: Tasklets are run by ksoftirq threads who are handled by Scheduler.

Tasklet 只是 softirq 的一种形式(由它们以TASKLET_SOFTIRQ优先级进行处理),因此运行tasklet的时间规则适用于它们.它们是根据罗伯特·洛夫(Robert Love)的书"Linux Kernel 开发":

Tasklet is just a form of softirq (it is handled by them with TASKLET_SOFTIRQ priority), so rules on when running tasklets applies to them. Here they are according to Robert Love's book "Linux Kernel Development":

  1. 在从硬件中断代码返回的路径中
  2. ksoftirq 内核线程中
  3. 在任何明确检查并执行挂起的softirq的代码中,例如网络子系统
  1. In the return from hardware interrupt code path
  2. In the ksoftirq kernel thread
  3. In any code that explicitly checks for and executes pending softirqs, such as the networking subsystem

如果默认值threadirqs=true(内核启动参数)似乎无法解决情况(1).

It seems that case (1) will not work if threadirqs=true (kernel boot parameter) which is default value.

UPD :关于与Scheduler的 ksoftirq 关系的一些说明.

UPD: Some notes on ksoftirq relation with Scheduler.

这似乎正在发生:

  1. hardirq 处理程序中,您唤醒 ksoftirq (由于tasklet_schedule())
  2. 因此wake_up_process()检查 ksoftirq 是否可以抢占当前线程
  3. 如果(2)为true,则设置TIF_NEED_RESCHED标志
  4. hardirq 返回时(在x86中为ret_from_intr-x86),已检查TIF_NEED_RESCHED标志
  5. 如果(4)为true,则调用schedule()尝试选择要执行的下一个线程.
  1. In hardirq handler you wake up ksoftirq (due to tasklet_schedule())
  2. Thus wake_up_process() checks if ksoftirq may preempt current thread
  3. If (2) is true TIF_NEED_RESCHED flag is set
  4. On the return from hardirq (ret_from_intr - in x86) TIF_NEED_RESCHED flag is checked
  5. If (4) is true, schedule() is called trying to pick next thread to be executed.

ksoftirq 很有可能在(2-3)中被视为抢占候选人,并在(5)中被选中,但是如果有竞争对手, ksoftirq 必须等到下一个schedule()周期-当前线程放弃(即睡眠),时钟滴答发生,系统调用或新的中断.

There is high chance that ksoftirq will be considered as preempt candidate in (2-3) and it will be picked in (5), but if there are competitors, ksoftirq have to wait till next schedule() cycle - current thread surrenders (i.e. sleeping), clock tick happens, syscall or new interrupt.

这篇关于ISR计划了tasklet之后,它究竟何时运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆