中断处理程序可以写入 FIFO

发布于 2024-10-10 08:04:52 字数 125 浏览 0 评论 0原文

我有一个线程正在等待 FIFO 上接收到的事件。 大多数事件是从同一进程中的另一个线程发送的配置事件。 我希望线程也能够通过让中断处理程序写入 FIFO 来处理中断事件,这可能吗?

欢迎任何其他建议而不是使用 FIFO!

I have a thread that is waiting for events received on a FIFO.
Most of events are configuration events send from another thread in the same process.
I would like the thread also to be able to handle interrupt events by having the interrupt handler writing to the FIFO is that possible?

Any other suggestion instead of using FIFO is welcome!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

挖个坑埋了你 2024-10-17 08:04:52

是的,可以。使用中断处理程序是处理异步 I/O 的较新方法之一。

更典型的方法是使用 select、poll 或 Linux epoll 命令。

这些可以说是更优选的,因为您可以在事件可用时处理事件并返回到“轮询”循环以获取更多事件,而不是在事件可用时“中断”您的代码完成 与先前的事件。这些机制可以同时等待多个不同的文件描述符,并返回可用的文件描述符。

中断处理程序可能不是您想要做的 - 因为您不一定希望在处理一个事件时被中断,以知道另一个事件已准备好。如果这样做,您可能最终会将请求排队以供稍后处理 - 这正是 poll 和 epoll 的开始目的。

如果您使用的是 Linux,“epoll”是最佳选择。如果您不这样做(或者想要符合 POSIX 标准),请使用“poll”。 “select”是一种“较旧”的方法,并且也不对请求进行排队。

Yes, it can. Using interrupt handlers is one of the newer ways of handling asynchronous I/O.

The more typical way of doing this, is with a select, poll, or Linux epoll command.

These are arguably a bit more preferred, because rather than "interrupting" your code when an event is available - you are able to handle events and return to the "poll" loop to get more events when you're done with the prior event. These mechanisms can wait on a number of different file descriptors at the same time, and return whichever one is available.

An interrupt handler is probably not what you want to do - because you don't necessarily want to be interrupted while processing one event, to know that another is ready. If you did, you'd probably wind up queuing the request anyway for later handling - which is exactly what poll and epoll to to begin with.

If you're under Linux, "epoll" is the most optimum. If your not, (or want POSIX compliance), use "poll". "select" is an "older" method, and doesn't queue requests as well.

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