和 ISR 的下半部分

发布于 2024-11-04 02:23:28 字数 118 浏览 5 评论 0原文

我在一次采访中被问到这个问题。 为什么中断服务例程的下半部分不允许有睡眠。我的答案是,由于在执行 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑脸一如从前 2024-11-11 02:23:28

以下是针对 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文