Messages in this thread | | | Date | Fri, 18 Oct 2002 10:41:28 -0700 (PDT) | From | Davide Libenzi <> | Subject | Re: epoll (was Re: [PATCH] async poll for 2.5) |
| |
On Fri, 18 Oct 2002, Dan Kegel wrote:
> 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.
Yes, I like coroutines :) even if sometimes you have to be carefull with the stack usage ( at least if you do not want to waste all your memory ). Since there're N coroutines/stacks for N connections even 4Kb does mean something when N is about 100000. The other solution is a state machine, cheaper about memory, a little bit more complex about coding. Coroutines though helps a graceful migration from a thread based application to a multiplexed one. If you take a thread application and you code your connect()/accept()/recv()/send() like the ones coded in the example http server linked inside the epoll page, you can easily migrate a threaded app by simply adding a distribution loop like :
for (;;) { get_events(); for_each_fd call_coroutines_associated_with_ready_fd(); }
- Davide
- 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/
| |