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.
Simplest coroutine implementations are truly simple.. Pagefull of C.
Knuth shows it with very few MIX (assembly) instructions.
Throwing in non-blocking socket/filedescriptor access, and in event
of "EAGAIN", coroutine-yielding to some other coroutine, does complicate
things, naturally.
Good coder finds balance in between various methods, possibly uses
both coroutine "userspace threads", and actual kernel threads.
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.
> -Corey
/Matti Aarnio
-
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/