Re: epoll (was Re: [PATCH] async poll for 2.5)

From: Dan Kegel (dank@kegel.com)
Date: Fri Oct 18 2002 - 12:28:38 EST


Mark Mielke wrote:
>>>>> while (read() == EAGAIN)
>>>>> wait(POLLIN);
>
> I find myself still not understanding this thread. Lots of examples of
> code that should or should not be used, but I would always choose:
>
> ... ensure file descriptor is blocking ...
> for (;;) {
> int nread = read(...);
> ...
> }
>
> Over the above, or any derivative of the above.
>
> What would be the point of using an event notification mechanism for
> synchronous reads with no other multiplexed options?
>
> A 'proper' event loop is significantly more complicated. Since everybody
> here knows this... I'm still confused...

I was afraid someone would be confused by the examples. Davide loves
coroutines (check out http://www.xmailserver.org/linux-patches/nio-improve.html )
and I think his examples are written in that style. He really means
what you think he should be meaning :-)
which is something like
     while (1) {
         grab next bunch of events from epoll
         for each event
             while (do_io(event->fd) != EAGAIN);
     }
I'm pretty sure.

- Dan

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



This archive was generated by hypermail 2b29 : Wed Oct 23 2002 - 22:00:43 EST