[lkml]   [2003]   [Jan]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: debate on 700 threads vs asynchronous code
Randy.Dunlap wrote:
> On Sat, 25 Jan 2003, Matti Aarnio wrote:
> | On Fri, Jan 24, 2003 at 04:53:46PM -0600, Corey Minyard wrote:
> | ...
> | > I would disagree. One thread per connection is easier to conceptually
> | > understand. In my experience, an event-driven model (which is what you
> | > end up with if you use one or a few threads) is actually easier to
> | > correctly implement and it tends to make your code more modular and
> | > portable.
> |
> | An old thing from early annals of computer science (I browsed Knuth's
> | "The Art" again..) is called Coroutine.
> |
> | Gives you "one thread per connection" programming model, but without
> | actual multiple scheduling threads in the kernel side. ...
> | Doing coroutine library all in portable C (by means of setjmp()/longjmp())
> | is possible, but not very efficient. A bit of assembly helps a lot.

There's also an elegant implementation that uses switch statements
or computed gotos; see
I'm using it. It's a bit limited, but hey, it works for me.

> Davide Libenzi (epoll) likes and discusses coroutines on one of his
> web pages:
> (search for /coroutine/)

IMHO coroutines are harder to use than either threads or nonblocking I/O.
Then again, I don't like Scheme; many things in this world are a matter of taste.
- Dan

Dan Kegel

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:32    [W:0.031 / U:0.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site