一个时间段内可以发生多少I/O次中断?

How many I/O interrupts can happen during a time period?

我不需要确切的数字,但我想知道典型的普通 pc 在 1 毫秒周期内读取输入中断的能力的现实意义。假设一只鼠标一直在移动,那么对于普通鼠标或游戏鼠标来说,有多少读取发生了,os?

换句话说,如果我们制作一个试图记录鼠标输入的程序,我们应该读取多少频率才能多次读取单个输入值?

这取决于硬件以及您所谈论的设备类型。 Intel 实际上为其 xHCI USB 控制器提供了最大中断率。我想说这个最大速率对于任何游戏鼠标来说可能都太高了。关于 xHCI (https://www.intel.com/content/dam/www/public/us/en/documents/technical-specifications/extensible-host-controler-interface-usb-xhci.pdf) 的英特尔文档在第 289 页指定

Interrupt Moderation allows multiple events to be processed in the context of a single Interrupt Service Request (ISR), rather than generating an ISR for each event.The interrupt generation that results from the assertion of the Interrupt Pending (IP) flag may be throttled by the settings of the Interrupter Moderation (IMOD) register of the associated Interrupter. The IMOD register consists of two 16-bit fields: the Interrupt Moderation Counter (IMODC) and the Interrupt Moderation Interval (IMODI).Software may use the IMOD register to limit the rate of delivery of interrupts to the host CPU. This register provides a guaranteed inter-interrupt delay between the interrupts of an Interrupter asserted by the host controller, regardless of USB traffic conditions.The following algorithm converts the inter-interrupt interval value to the common 'interrupts/sec' performance metric:

Interrupts/sec = (250×10-9sec × IMODI) -1

For example, if the IMODI is programmed to 512, the host controller guarantees the host will not be interrupted by the xHC for at least 128 microseconds from the last interrupt. The maximum observable interrupt rate from the xHC should not exceed 8000 interrupts/sec.Inversely, inter-interrupt interval value can be calculated as:

Inter-interrupt interval = (250×10-9sec × interrupts/sec) -1

The optimal performance setting for this register is very system and configuration specific. An initial suggested range for the moderation Interval is 651-5580 (28Bh -15CCh). The IMODI field shall default to 4000 (1 ms.) upon initialization and reset. It may be loaded with an alternative value by software when the Interrupter is initialized

USB 与 xHCI 一起工作,为系统提供中断。我不是硬件工程师,但我会说中断速度取决于鼠标频率。例如这只鼠标:https://www.amazon.ca/Programmable-PICTEK-Computer-Customized-Breathing/dp/B01G8W30BY/ref=sr_1_4?dchild=1&keywords=usb+gaming+mouse&qid=1610137924&s=electronics&sr=1-4,频率为 125HZ 到 1000HZ。这可能意味着您将获得 125/s 到 1000/s 的中断频率,因为鼠标具有此频率。它的光学传感器将以该频率检查鼠标所在的表面,从而中断移动。

至于自己打断,我觉得要看速度了CPU。在处理时,中断会被屏蔽一小段时间。最快的 CPU,最快的中断将被揭露,最快的新中断可以发生。我会说这里的瓶颈是鼠标有 1000 interrupts/s,即 1 interrupt/ms.