Why does USB use a polling mechanism instead of an interrupt to detect the device?
I've read here on Stack Overflow that if the event is
then we can use polling. But in case of USB, device detection is not frequent, so an interrupt mechanism would be better.
Thanks for your replies,
Zaheer
Polling rate is the speed at which your mouse communicates input to your computer. Over USB, the base polling rate is usually 125Hz, or once every 8 milliseconds. Most gaming mice, however, typically include a 1000Hz polling rate, once per millisecond, or 1000 times per second. What is this?
A USB device can support interrupt endpoints so that it can send or receive data at regular intervals. To accomplish that, the host polls the device at regular intervals and data is transmitted each time the host polls the device. Interrupt transfers are mostly used for getting interrupt data from the device.
USB device communication is done through pipes. These pipes are a connection pathway from the host controller to an addressable buffer called an endpoint. An endpoint stores received data from the host and holds the data that is waiting to transmit to the host.
USB has four different packet types. Token packets indicate the type of transaction to follow, data packets contain the payload, handshake packets are used for acknowledging data or reporting errors and start of frame packets indicate the start of a new frame. Token Packets.
There is no way for a USB device to "interrupt" its host controller in the same manner as other hardware interrupts. USB does support an Interrupt transfer method, but this is in fact implemented by polling 1 and the latency one can achieve is about 1 ms, but ultimately limited by the host's performance.
You asked
Why does USB polling mechanism instead of interrupt to detect the device?
Well, one reason would be that the USB protocol simply does not support interrupts at all in the usual hardware sense, most likely to keep the protocol simpler. For example, if a device wanted to interpret a transfer that was in progress, it would have to signal this somehow, either by corrupting an existing transfer, or an extra signal line would have to be added to whole system. Quickly polling the bus in hardware is fast enough for most types of devices.
Note that detecting a new device fails all three of your points where polling is recommended. Indeed, we never know when to expect a new USB device to appear on the bus (#1), it happens rarely (#3) and in the device is not active detecting it immediately is not a priority (#2). Why waste time and energy checking for an event that is unlikely to occur?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With