- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个源以 819.2 赫兹(~1.2 毫秒)的速率向我的 QNX Neutrino 机器发送 UDP 数据包。我希望以尽可能少的延迟和抖动来接收和处理这些消息。
我的第一个代码基本上是:
SetupUDPSocket();
while (true) {
recv(socket, buffer, BufferSize, MSG_WAITALL); // blocks until whole packet is received
processPacket(buffer);
}
问题在于 recv() 仅在系统的每个计时器滴答时检查是否有可用的新数据包。计时器滴答声通常为 1 毫秒。所以,如果我使用它,我会得到一个巨大的抖动,因为我每 1 毫秒或每 2 毫秒处理一个数据包。我可以重置计时器滴答的大小,但这会影响整个系统(以及其他进程的其他计时器等)。而且我仍然会有抖动,因为我肯定永远不会完全匹配 819.2 Hz。
于是,我尝试使用网卡的中断线(5)。但似乎还有其他因素导致中断上升。我曾经使用以下代码:
ThreadCtl(_NTO_TCTL_IO, 0);
SIGEV_INTR_INIT(&event);
iID = InterruptAttachEvent(IRQ5, &event, _NTO_INTR_FLAGS_TRK_MSK);
while(true) {
if (InterruptWait(0, NULL) == -1) {
std::cerr << "errno: " << errno << std::endl;
}
length = recv(socket, buffer, bufferSize, 0); // non-blocking this time
LogTimeAndLength();
InterruptUnmask(IRQ5, iID;
}
这会导致在开始时读取一次成功,然后在 0 次之后读取 0 字节长度。看起来,在执行 InterruptUnmask() 之后,InterruptWait() 根本没有等待,所以一定已经有一个新的中断(或相同?!)。
是否可以用网卡的中断线做类似的事情?是否还有其他可能以 819.2 Hz 的速率接收数据包?
网卡的一些信息:'pci -vvv' 输出:
Class = Network (Ethernet)
Vendor ID = 8086h, Intel Corporation
Device ID = 107ch, 82541PI Gigabit Ethernet Controller
PCI index = 0h
Class Codes = 020000h
Revision ID = 5h
Bus number = 4
Device number = 15
Function num = 0
Status Reg = 230h
Command Reg = 17h
I/O space access enabled
Memory space access enabled
Bus Master enabled
Special Cycle operations ignored
Memory Write and Invalidate enabled
Palette Snooping disabled
Parity Error Response disabled
Data/Address stepping disabled
SERR# driver disabled
Fast back-to-back transactions to different agents disabled
Header type = 0h Single-function
BIST = 0h Build-in-self-test not supported
Latency Timer = 40h
Cache Line Size= 8h un-cacheable
PCI Mem Address = febc0000h 32bit length 131072 enabled
PCI Mem Address = feba0000h 32bit length 131072 enabled
PCI IO Address = ec00h length 64 enabled
Subsystem Vendor ID = 8086h
Subsystem ID = 1376h
PCI Expansion ROM = feb80000h length 131072 disabled
Max Lat = 0ns
Min Gnt = 255ns
PCI Int Pin = INT A
Interrupt line = 5
CPU Interrupt = 5h
Capabilities Pointer = dch
Capability ID = 1h - Power Management
Capabilities = c822h - 28002000h
Capability ID = 7h - PCI-X
Capabilities = 2h - 400000h
Device Dependent Registers:
0x040: 0000 0000 0000 0000 0000 0000 0000 0000
...
0x0d0: 0000 0000 0000 0000 0000 0000 01e4 22c8
0x0e0: 0020 0028 0700 0200 0000 4000 0000 0000
0x0f0: 0500 8000 0000 0000 0000 0000 0000 0000
和“nicinfo”输出:
wm1:
INTEL 82544 Gigabit (Copper) Ethernet Controller
Physical Node ID ........................... 000E0C C5F6DD
Current Physical Node ID ................... 000E0C C5F6DD
Current Operation Rate ..................... 100.00 Mb/s full-duplex
Active Interface Type ...................... MII
Active PHY address ....................... 0
Maximum Transmittable data Unit ............ 1500
Maximum Receivable data Unit ............... 0
Hardware Interrupt ......................... 0x5
Memory Aperture ............................ 0xfebc0000 - 0xfebdffff
Promiscuous Mode ........................... Off
Multicast Support .......................... Enabled
感谢阅读!
最佳答案
我不太确定为什么声明 “问题是 recv() 仅在系统的每个计时器滴答时检查是否有可用的新数据包。计时器滴答通常为 1 毫秒。” 对于抢占式操作系统来说是正确的。肯定是系统配置有问题或者网络协议(protocol)栈实现有问题。
几年前,当我为 Yahoo BB Japan 做一些 IPTV STB 项目时,我遇到了 RTP 接收问题。问题不是延迟或抖动,而是我们添加一些 NDS 算法后 STB 中的整体系统性能。我们正在使用 vxWorks,vxWorks 支持以太网 Hook 接口(interface),驱动程序每次收到以太网数据包时都会调用该接口(interface)。
我将一个 API 挂接到它,然后直接从以太网数据包中解析具有指定端口的 UDP。当然我们有一些假设没有碎片,这是由性能问题的网络设置保证的。也许您还可以查看是否可以在 QNX 以太网驱动程序中获得相同的 Hook 。至少您会发现抖动是否来自驱动程序。
关于c++ - 使用 QNX RTOS 实时接收 UDP 数据包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11867871/
假设有 6 个任务,在 6 个中,有 4 个(任务)正在等待一个信号量。当信号量发出信号时, 会做出什么决定?实时操作系统 which tasks to pick from the waiting(f
我希望编写一个非常基本的 RTOS,它可以在两个任务之间切换。它不适合任何专业用途。只是为了好玩 大多数引用资料都是关于如何使用 RTOS,而不是如何编写 RTOS。 引用像 FreeRTOS 这样的
如果有人可以解释 RTOS 中的滴答率过高的影响,或者指导我找到清楚解释它的资源,我将不胜感激? 问题的上下文... 我们使用 ucos-ii 运行,滴答率为 10000 (OS_TICKS_PER_
Zephyr 实时操作系统 https://www.zephyrproject.org/是一个 Linux 基金会项目。 Linux 以其 GPL 许可证而闻名。那么为什么 Zephyr RTOS 使
假设有两个任务正在运行TASK_A和TASK_B。当TASK_A运行时,发生中断,需要将上下文切换到TASK_B。 在ISR内时,不应直接跳过TASK_B,因为它仍在ISR中并且尚未返回(例如:未执行
我想了解操作系统节拍时间是什么意思,它有什么用? 以及它与 CPU 节拍率有何不同 最佳答案 系统节拍是操作系统计时器和延迟所基于的时间单位。系统节拍是一个调度事件 - 即它会导致调度程序运行并可能导
我正在尝试从头开始学习 RTOS,为此,我使用 freeRTOS.org 作为引用。我发现这个站点是学习 RTOS 的最佳资源。但是,我有一些疑问,我试图找出答案,但无法得到确切的答案。 1) 如何找
在基于 ARM7 的 C 语言编程的嵌入式应用程序中(具有可移植性要求),当前使用基于商业优先级的抢占式 RTOS,我们需要根据客户要求删除该 RTOS 和任何 RTOS 依赖项。我们有 8 个任务使
我对嵌入式世界还很陌生。我在为基于 ARM M0+ 的飞思卡尔微处理器编码固件方面有一些经验。我目前正在使用 CML-5282 开发板 (M5282LITE) 进行一个新项目,它带有 RTXC Qua
首先是背景,我的问题的细节如下: 在我工作的公司,我们工作的平台目前是 Microchip PIC32 系列,使用 MPLAB IDE 作为我们的开发环境。以前,我们还为同一应用编写了 Microch
FreeRTOS 使用什么样的调度程序? 我在某处读到它是一个运行完成调度程序,但另一方面,我也看到它与并行任务一起使用,所以它不会是一个循环调度程序? 最佳答案 最高优先级的任务被授予CPU时间。如
我正在对 TI 的一 block 板进行编程,并且我希望能够以某种方式将两个不同的 ISR 发布到任务的消息队列中。那部分工作正常。但是,在接收端,是否有任何智能方法可以让任务挂起在队列中,并根据发布
FreeRTOS 使用什么样的调度程序? 我在某处读到它是一个运行完成调度程序,但另一方面,我也看到它与并行任务一起使用,所以它不会是一个循环调度程序? 最佳答案 最高优先级的任务被授予CPU时间。如
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
我正在编写一个模块,其中包含一个具有最高优先级的任务,并且它应该处于阻塞状态,直到它收到来自其他任务的消息,开始履行其作为最高优先级任务的职责。它使用邮箱机制进行信令。 我的问题是我希望任务 - 向更
所以我对为我实现的游戏形成线程的最佳方法有点困惑。游戏非常简单,你必须操纵你的飞船来躲避来袭的墙壁。 目前我的代码只是循环执行,直到宇宙飞船爆炸。以此 while 循环表示(如果游戏结束,notBlo
我对创建任务的 RTOS 方法不熟悉。之前,我在 Raspberry Pi 上使用 pthread,这使我能够同时运行 2 个任务, 1)每2秒通过套接字发送数据 2)每当从客户端发送数据时,通过套接
简单背景: 在我的 MCU 上运行 freeRTOS。 我的项目中的功能之一是一个处理存储在外部存储器中的参数的库。 基本上在启动时,主函数调用从外部存储器读取所有参数并将它们存储在库内的静态变量(非
我想编写一个需要一些 RTOS API(例如 Mbox 和任务创建 API)的模块! 我正在尝试使用结构化代码并为此查看一些库,例如“lwip”。在“lwip”中有一个名为 Sys-arch.c 的文
我有一个现有的嵌入式源代码,它直接在没有操作系统的微 Controller 上运行。我需要移植代码以在特定的 RTOS 上运行。 在尝试做某事时,是否有关于从哪里开始的指导方针?资源、最佳实践和其他见
我是一名优秀的程序员,十分优秀!