clone() really _is_ very lightweight. I think that some of the confusion
comes from the timings of "pthread_create()" which is much less
lightweight partly due to memory allocation issues, partly just because
the Linux clone-based pthreads library hasn't had all that much time to be
I'd be very surprised if a basic clone() call is any slower than even the
lightest-weight Solaris kernel threads: there really is almost no overhead
at all: most of it is a fairly simple memory allocation plus some slight
copying of kernel state to the new thread.
And partly _because_ Linux kernel threads created with clone() are not a
special case but a first-class citizen with any other process, a lot of
code is actually simplified and speeded up. For example, the context
switching doesn't have any special cases etc (it has a weight factor that
tries to give priority to threads that share the same memory management,
but that's a fairly simple mechanism for better performance).
I'm sure people can find threads that are even more light-weight than
clone(), but I don't think they'll be as generic as clone(), and I doubt
they'll be _much_ faster.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to email@example.com