linux进程被中断打断,linux – 当中断处理程序被另一个中断中断时,中断上下文如何“恢复”?...

我读了一些相关的帖子:

You cannot sleep in an interrupt handler because interrupts do not have a backing

process context, and thus there is nothing to reschedule back into. In other

words, interrupt handlers are not associated with a task, so there is nothing to

"put to sleep" and (more importantly) "nothing to wake up". They must run

atomically.

If sleep is allowed, then the linux cannot schedule them and finally cause a

kernel panic with a dequeue_task error. The interrupt context does not even

have a data structure describing the register info, so they can never be scheduled

by linux. If it is designed to have that structure and can be scheduled, the

performance for interrupt handling process will be effected.

所以在我的理解中,中断处理程序在中断上下文中运行,并且无法休眠,也就是说,不能像正常进程那样使用支持机制执行上下文切换.

但是中断处理程序可能被另一个中断中断.当第二个中断处理程序完成其工作时,控制流将跳回第一个中断处理程序.

如果没有正常的上下文切换,这种“恢复”是如何实现的?它是否像普通函数调用一样,所有寄存器和其他相关内容都存储在某个堆栈中?

解决方法:

简短的回答是,如果中断处理程序可以被中断中断,则中断处理程序的中断方式与中断中断的任何其他内容完全相同.

假设进程X正在运行.如果进程X被中断,则中断处理程序运行.在某种程度上存在上下文的情况下,它仍然处理X,尽管它现在在内核中运行中断代码(如果你愿意,可以将状态视为X->中断).如果发生另一个中断,则中断被中断,但仍然没有特殊的进程上下文.现在状态是X-> first_interrupt-> second_interrupt.当第二个中断结束时,第一个中断将恢复,就像第一个中断结束时X将恢复一样.但是,唯一的过程上下文是过程X.

您可以将它们描述为上下文切换,但它们与流程上下文切换不同.它们更类似于进入和退出内核 – 进程上下文保持不变,但执行级别和代码单元可能会发生变化.

标签:linux,interrupt,linux-kernel

来源: https://codeday.me/bug/20190725/1532068.html

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值