Re: Threads question

Larry McVoy (
Thu, 24 Apr 1997 14:40:34 -0700

: I often hear about how lightweighted linux processes and thus threads
: (based on clone) are. However I have not heard of how many it can easily
: handle, or even of a maximum number. More precisely, I am thinking of
: designing a GUI library that could use one thread per window. It is safe
: to say that an average application could have 100 windows, so that an
: average system could easily have 1000 windows totalling 1000 threads.
: Can the linux kernel cope with thousands of threads?

A better question is "can your system cope with a 1000 threads?". It is
sad but true that threads have been overhyped - not by the Linux folks,
those threads are as good or better than any. You have a basic memory
problem that others have independently discovered. Each thread needs a
stack, which is probably at least a 4K page or more. That's 4mb of memory
for just the stack, let alone any thread specific data.

A choice between a window system that was threaded and 4mb bigger than
a window system that used events would be an easy choice for many to make.
Especially since threaded window systems don't work very well. Great for
demos, crappy in real life.

Think of it this way: threads are like salt, not like pasta. You like
salt, I like salt, we all like salt. But we eat more pasta :-)
Same breakdown for threads vs other programming models. Contrary to
all the hype, threads != pasta.

Not what you wanted to hear, I'm sorry to say.