Linus Torvalds wrote:
> > I would not call 8K/16K overhead "lightweight" treading.
> Oh, and pray tell how much you expect a kernel thread to take?
A stack page is _not_ required for a kernel thread, except when that
thread is blocked. A sleeping but runnable task doesn't require a stack.
That leaves approximately sizeof (struct task_struct).
(Similar optimisations are possible in user space).
> The memory overhead is negligible. An app that thinks that 16kB/thread is
> too much, should not be using kernel threads in the first place. You could
> argue that it probably shouldn't be using threads at _all_.
The alternative is user space lightweight threads which as we know can
be very light indeed - comparable with procedure calls and event loops.
Unfortunately, with Linux, you lose the possibility to do system calls
from those kind of threads without blocking the other threads. Hacks
involving timer signals can work around this but at some performance
So you have to choose -- system calls, or lightweight threads?
There's a nice way to get the best features of both. Simply: when a
kernel thread blocks (reading from disk or whatever), wake up another
kernel thread. User space can handle the rest. I think this was called
"scheduler activations" or something like that.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to firstname.lastname@example.org
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Thu Aug 31 2000 - 21:00:15 EST