和 ISR 的下半部分
我在一次采访中被问到这个问题。 为什么中断服务例程的下半部分不允许有睡眠。我的答案是,由于在执行 ISR 时中断将被屏蔽,如果下半部分有睡眠,我们将错过一些中断。我无法思考这是正确的答案吗?任何人都可以想到任何其他原因吗?
I was asked this question in an interview.
Why is the bottom half of an interrupt service routine not allowed to have sleeps in it.My answer was that since the interrupts will be masked while executing the ISR we will miss some interrupts if the bottom halves have sleeps.I was not able to think of anything else.Is this the right answer.Can anyone think of any other reason for this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是针对 Linux 的。
下半部有两种类型。第一个由软中断和微线程组成。
Tasklet 是基于软中断构建的,并且非常相似。这两个不在进程上下文中运行,因此它们无法睡眠。
第二种是工作队列,它运行在内核线程中并且可以休眠。
有一些下半部分必须睡觉。据我所知,网络系统使用工作队列。我已经写了睡觉的下半部分。
也许你问的是上半身因为两个原因而无法入睡。它们不是在进程上下文中运行,因此它们不能并且应该尽可能快地执行,并将所有工作推迟到下半部分,如果需要,下半部分将休眠。
The following is for Linux.
There are two types of bottom halves. The first one is comprised of softirqs and tasklets.
Tasklets are build upon softirqs and are very similar. These 2 don't run in process context so therefore they can't sleep.
The second type is workqueue which runs in a kernel thread and can sleep.
There are some bottom halves which have to sleep. To the best of my knowledge the network system uses workqueues. I have written bottom halves that sleep.
Maybe you were asking about top halves which can't sleep out of 2 reasons. They are not running in a process context, therefore they can't and they should be executed as fast as possible and deffer all work to bottom halves, which if needed will sleep.