Re: The need for poll2()

Richard Gooch (rgooch@atnf.CSIRO.AU)
Sun, 24 Aug 1997 15:34:31 +1000


Colin Plumb writes:
> May I suggest a simpler hack? Add a second return value to the poll
> system call, which is the index of the first pollfd which has an
> event. poll already returns the number of pollfds, and if that
> return value is 1, you don't need to scan. If it's more than 1,
> you need to scan, but since you've thus managed to avoid another
> call to poll, I'm not really worried about it.
>
> That way you can do poll2(), or anything similar, in libc, with
> minimal overhead.

I don't understand how your suggestion can help much. If there are a
small number of descriptors ready, say 10, then your scheme saves you
from scanning for the first. If they are spaced roughly evenly, then
all you've done is saved 10% of the scanning.
Of course, you really don't want to call poll(2) every time you've
finished dealing with a single descriptor (because poll(2) is an
expensive operation).

What do you mean by "you've thus managed to avoid another call to
poll"? Am I missing something?

Regards,

Richard....