Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

USB polling mechanism

Tags:

polling

usb

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

  1. Synchronous (i.e. you know when to expect it within a small window)
  2. Not Urgent (i.e. a slow polling interval has no ill effects), and
  3. Frequent (i.e. majority of your polling cycles create a 'hit')

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

like image 440
Zaks Avatar asked Jan 27 '11 06:01

Zaks


People also ask

What is polling in USB?

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?

Does USB use polling or interrupt?

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.

What kind of communication method is used in USB?

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.

What is USB handshake?

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.


1 Answers

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?

like image 53
jbarlow Avatar answered Oct 09 '22 17:10

jbarlow