Re: poll() in 2.6 and beyond

From: Roland Dreier
Date: Tue Mar 02 2004 - 16:42:39 EST


Roland> I don't think so. Even in kernel 2.4, poll_wait() just
Roland> calls __pollwait(). I don't see anything in __pollwait()
Roland> that sleeps. Think about it. How would the kernel handle
Roland> userspace calling poll() with more than one file
Roland> descriptor if each individual driver slept?

Richard> Well what to you think they do? Spin?

I don't know why I continue this, but.... can you point out the line
in the kernel 2.4 source for __pollwait() where it sleeps?

Or think about it. Suppose a user called poll() with two fds, each of
which belonged to a different driver. Suppose each driver slept in
its poll method. If the first driver never became ready (and stayed
asleep), how would poll() return to user space if the second driver
became ready?

What actually happens is that each driver registers with the kernel
the wait queues that it will wake up when it becomes ready. But the
core kernel is responsible for sleeping, outside of the driver code.

Really, read:
<http://www.xml.com/ldd/chapter/book/ch05.html#t3>

You might believe you're familiar with poll() but I think it would
help to read what the Linux Device Drivers book has to say. It
answers the exact question you're asking, and if you don't believe me
you might believe the definitive published book.

- Roland
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/