From: yoxoman on
Hello,

It seems that polling is the "dirty" way of using a device, whereas
interrupt is the prefered one, but that one implies some context
switching delays.

Are there still devices today on which polling is used (I think of
keyboard and mouse, but I'm not sure) ? Are the both techniques used on
some devices ? Does it depend on the OS ?

Thanks.
From: FredK on

"yoxoman" <invalid(a)invalid.invalid> wrote in message
news:4beb9b60$0$24516$426a74cc(a)news.free.fr...
> Hello,
>
> It seems that polling is the "dirty" way of using a device, whereas
> interrupt is the prefered one, but that one implies some context
> switching delays.
>
> Are there still devices today on which polling is used (I think of
> keyboard and mouse, but I'm not sure) ? Are the both techniques used on
> some devices ? Does it depend on the OS ?
>
> Thanks.

Even old PS2 kb/mice are usually run in interrupt mode.

Unless you are spinning on a register (tying up a CPU), "polling" generally
relies on a repeating timer interrupt to call the driver to check the
device. A direct interrupt from the device will provide lower latency and
only happens when the device needs service - but ultimately an interrupt
(timer or the device itself) causes the check of the device. Polling tends
to be used when for some reason or another the interrupt is unreliable
(broken hardware design).



From: Andy 'Krazy' Glew on
On 5/13/2010 6:09 AM, FredK wrote:
> "yoxoman"<invalid(a)invalid.invalid> wrote in message news:4beb9b60$0$24516$426a74cc(a)news.free.fr...
>> It seems that polling is the "dirty" way of using a device, whereas
>> interrupt is the prefered one, but that one implies some context
>> switching delays.
>>
>> Are there still devices today on which polling is used (I think of
>> keyboard and mouse, but I'm not sure) ? Are the both techniques used on
>> some devices ? Does it depend on the OS ?
>
> Even old PS2 kb/mice are usually run in interrupt mode.
>
> Unless you are spinning on a register (tying up a CPU), "polling" generally
> relies on a repeating timer interrupt to call the driver to check the
> device.

Coding Horror: Mouse DPI and USB Polling Rate
Apr 2, 2007 ... The default USB polling rate is 125 Hz, which means the mouse cursor can only be updated every 8
milliseconds. ...
www.codinghorror.com/blog/archives/000832.html - Cached - Similar

From wikipedia

The host controller directs traffic flow to devices, so no USB device can transfer any data on the bus without an
explicit request from the host controller. In USB 2.0, the host controller polls the bus for traffic, usually in a
round-robin fashion. The slowest device connected to a controller sets the bandwidth of the interface.


From: FredK on

"Andy 'Krazy' Glew" <ag-news(a)patten-glew.net> wrote in message
news:4BEC1994.7040809(a)patten-glew.net...
> On 5/13/2010 6:09 AM, FredK wrote:
>> "yoxoman"<invalid(a)invalid.invalid> wrote in message
>> news:4beb9b60$0$24516$426a74cc(a)news.free.fr...
>>> It seems that polling is the "dirty" way of using a device, whereas
>>> interrupt is the prefered one, but that one implies some context
>>> switching delays.
>>>
>>> Are there still devices today on which polling is used (I think of
>>> keyboard and mouse, but I'm not sure) ? Are the both techniques used on
>>> some devices ? Does it depend on the OS ?
>>
>> Even old PS2 kb/mice are usually run in interrupt mode.
>>
>> Unless you are spinning on a register (tying up a CPU), "polling"
>> generally
>> relies on a repeating timer interrupt to call the driver to check the
>> device.
>
> Coding Horror: Mouse DPI and USB Polling Rate
> Apr 2, 2007 ... The default USB polling rate is 125 Hz, which means the
> mouse cursor can only be updated every 8 milliseconds. ...
> www.codinghorror.com/blog/archives/000832.html - Cached - Similar
>
> From wikipedia
>
> The host controller directs traffic flow to devices, so no USB device can
> transfer any data on the bus without an explicit request from the host
> controller. In USB 2.0, the host controller polls the bus for traffic,
> usually in a round-robin fashion. The slowest device connected to a
> controller sets the bandwidth of the interface.
>

I assumed the question referred to a device driver on a computer system, not
the implementation of the mechanism the USB controller uses to talk to a
device connected to is - as opposed to USB port driver interface to the host
controller.

The mouse input comes from an input interrupt pipe. Most mice I've seen
request a 10ms polling rate (host/device) which is usually rounded down to 8
when putting it into the schedule - which is not the sampling rate which
IIRC can be set via a device command. The interrupt schedule is a list
which the host controller scans IIRC in V1.1 at the frame rate (1ms) and on
2.0 at a microframe (8 frames). The host controller then polls the device
at that rate, delivers data when available from the device and then
interrupts the host system to operate on any completed data input (which it
does by scanning the data structures that are hung off the schedule list.

Not to rat hole on the warped sense of humor the USB designers had.



From: yoxoman on
On Thu, 13 May 2010 09:09:21 -0400, FredK wrote:

> [...] Unless you are spinning on a register (tying up a CPU) [...]

OK. And does that happen in real life today ?


Thank you for your answer.