[NTLUG:Discuss] pthreads on Linux
Steve Baker
sjbaker1 at airmail.net
Sat Aug 11 11:06:09 CDT 2001
Chris Cox wrote:
>
> I know previously Linus and others claimed that threads were not
> needed in Linux because they wouldn't buy that much in performance.
For once, Linus was wrong. We've used threads at work and they certainly
do help THE RIGHT KIND OF APPLICATION.
However, it's not that this is a kind of magic wand. If you have only
one CPU and your application is just doing heavy CPU/memory work, then
splitting it into two threads can only hurt performance.
But if your application mixes calculations with I/O, then of course
threading helps - while one thread is doing I/O, the other can use
the CPU for doing calculations - and vice-versa.
Then if you have multiple CPU's, a single threaded application can't
possibly gain any benefit from that second CPU - so you pretty much
HAVE to have threads to take advantage of it.
HOWEVER, that's not a magical guarantee of speedup if (as I suspect
here) you are main memory bandwidth bound...the only solution then
is to restructure your code so that you are no longer memory bound
- or to go to a Beowulf style solution where you are running on
multiple computers. If you *can* restructure your application to
run on a Beowulf cluster (and it's NOT a trivial matter to do that)
then you have multiple RAM banks and memory busses and thereby
increase net RAM bandwidth over the entire distributed system.
----------------------------- Steve Baker -------------------------------
HomeMail : <sjbaker1 at airmail.net> WorkMail: <sjbaker at link.com>
HomePage : http://web2.airmail.net/sjbaker1
Projects : http://plib.sf.net http://tuxaqfh.sf.net
http://prettypoly.sf.net http://tuxkart.sf.net
http://freeglut.sf.net http://toobular.sf.net
More information about the Discuss
mailing list