read with timeout ??

Nate Eldredge neldredge at math.ucsd.edu
Fri Aug 8 22:51:23 UTC 2008


On Fri, 8 Aug 2008, Chuck Robey wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Pieter de Goeje wrote:
>>
>> I think poll(2) is also simpler than select for this purpose.
>>
>
> It does look like that, I need to check the implementation a bit, because the
> name of this thing makes me really suspicious about how often it checks for an
> fd for being ready for a read.  I know select comes right back, I was under the
> impression that poll didn't use signals to do this.

AFAIK the effects are identical, just the arguments are set up in a 
different way.  Both of them will block until the fd is ready and then 
return "immediately" (subject to other processes running of course).  The 
name "poll" is a misnomer because it doesn't actually work by polling, 
but you can pretend that it does (and does so "infinitely often"). 
Neither one uses signals per se, though if the underlying hardware device 
is interrupt-driven, that will be what (indirectly) triggers the wake-up.

poll does seem to be more convenient than messing about with fd_set's. 
select is older and so it comes to my mind first, that's all.

-- 

Nate Eldredge
neldredge at math.ucsd.edu


More information about the freebsd-hackers mailing list