如何将客户端的recv()部分更改为中断服务例程?

发布于 2024-11-06 18:05:52 字数 140 浏览 0 评论 0原文

我目前有一个客户端在其自己的线程中侦听数据包。有人告诉我尝试实现 ISR,以便可以立即处理从 recv() 调用接收到的数据包,而不是等待该线程被调度。

编辑:现在是在 Windows 中,但稍后会移植到 DSP。

I currently have a client listening for packets in its own thread. I was told to try to implement an ISR so that the packet received from the recv() call can be handled immediately, instead of waiting for that thread to get scheduled.

EDIT: this is in windows now, but it will ported to a DSP later.

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

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

发布评论

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

评论(1

妖妓 2024-11-13 18:05:52

根据定义,ISR 在内核空间中运行。除非您处于没有内存保护的嵌入式系统中,否则您需要将内核代码添加到您的项目中。此外,为了重新实现recv,它需要根据需要处理IP和TCP或UDP,以从以太网数据包中提取数据。

重新调度和切换到线程的开销是最小的,并且无论如何都需要发生,除非数据包完全在内核中处理。大多数操作系统都有最高优先级的线程设置,有时称为“实时”,这会导致用户空间代码在驱动程序接收数据后以最小的延迟运行。这通常用于音频/视频 I/O 以及网络。

ISRs by definition run in kernel space. Unless you are in an embedded system without memory protection, you will need to add kernel code to your project. Furthermore, to reimplement recv, it will need to handle IP and TCP or UDP as necessary to extract the data from the ethernet packets.

The overhead of rescheduling and switching to a thread is minimal, and needs to happen anyway unless the packet is handled entirely in the kernel. Most operating systems have a highest-priority thread setting, sometimes called "real-time," which causes user space code to run with minimal delay after the driver receives data. This is often used for audio/video I/O as well as networking.

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