[NTLUG:Discuss] pthreads on Linux
Chris Cox
cjcox at acm.org
Fri Aug 10 22:30:27 CDT 2001
I know previously Linus and others claimed that threads were not
needed in Linux because they wouldn't buy that much in performance.
Anyone else have any stories on this?
"Peter A. Koren" wrote:
>
> I just wrote a threaded version (pthreads) of a C program which has one
> main thread and typically 50 to 100 child threads. I have an ABIT BP-6
> dual processor motherboard and am running Mandrake 8.0 with SMP kernel
> version 2.4.3. I was hoping to get a speed up. No such luck.
>
> The threaded version does use both processors at high utilization rates,
> as confirmed by "top." The algorithm, BTW, is a differential evolution
> code, which is a clever cross between simulated annealing and genetic
> algorithms. On "toy" problems, with little computation per thread, the
> non threaded version runs about an order of magnitude faster, indicating
> much more overhead for threading. But even when I add a very long
> running delay loop for each thread, the threaded version takes about 50%
> more time.
>
> I added more memory 128MB => 256 MB. It did nothing. I changed from
> using a join approach to a detached thread model with semaphores to
> synchronize threads, and it helped take 20 seconds off the threaded
> benchmarks, for both the "toy" threads and the longer running threads
> with built in delay loops. But I just can't find a way to make threads
> pay off.
>
> I thought that threads under Linux were quite efficient with two
> processors, as that is what is widely claimed. Do any of you have any
> relevant experience? Have you seen gains using threads on
> multi-processor systems?
>
> Pete Koren
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss
More information about the Discuss
mailing list