How many times does the poll method in device driver get called for each application select?

How many times does the poll method in device driver get called for each application select?

Post by Linda Citr » Sat, 05 Apr 2003 16:37:36


I noticed that my poll method gets called twice for each one application select
call.  Is that correct?  Why does it that?
( I call select without a timeout, so that it should
wait forever)



1. Race conditions in driver select and poll methods

In the Linux Device Drivers book of Rubini, the problem of avoiding race conditions is discussed.
In the section "Going to Sleep Without Races" (pages 203-210) two methods are given to avoid the problem that between testing if
data is available, and calling interruptible_sleep_on () an interrupt may occur, causing a race condition.
The methods given there, work fine in the driver's read and write methods, but we don't see how they can be applied to the select or
poll methods.
Rubini's approach is, instead of calling interruptible_sleep_on(), the code in this function is written out, and the sequence of
testing, adding ourselves to a wait queue, setting TASK_INTERRUPTIBLE and calling schedule() is slightly re-ordered so that the race
condition is avoided.

But in select or poll, there is no such call to a sleep or schedule routine; instead if none of the files specified in the select
mask has data available, it is the kernel who calls schedule. In our opinion this can also lead to the same race condition as in
read and write.

We have the feeling that calling cli() before the race condition could occur, is not a good thing to do here.
Any idea if we are right or wrong, and if right, how such a race condition can be avoided in the select or poll methods?

Peter Kroon.

2. Linux Application Server

3. Poll()/select() device driver - new version available

4. Mobile Computing with LINUX

5. My Freebsd driver hangs in poll function after some time (problem with poll)

6. Firewall Testing -- HELP!!

7. Select call for a device driver problem

8. Problems with Maple V R4

9. Device driver calling another device driver.

10. Converting select() calls to poll()

11. looking for select() source that calls poll()

12. poll/select in udprelay - anyone have poll.c(h) code for linux?

13. Final STEP on 5.0 (redhat) keep getting ERROR message when selecting boot METHOD