On Tuesday 08 Feb 2011 10:05:47 Dr.Ruud wrote:
> On 2011-02-07 11:30, Shlomi Fish wrote:
> > Threads work pretty well in C, though they are extremely tricky to get
> > right for non-trivial programs
> 
> That they work "pretty well" is probably about user experience of some
> heavily interactive system. But only if the user accepts crashes and
> deadlocks now and then.
> 

What I meant by work pretty well, is that they are lightweight, cheap, perform 
well, and can often increase performance. 

> The "tricky to get right" misses the point that systems based on threads
> have no proper math to back them up.
> 

[citation needed]. I believe I've seen some mathematical models of threads, 
and you can prove the lack of deadlocks/livelocks/etc. in a model of the 
system mathematically. But like you said, if one is going to implement 
cooperative threads that work using the same resources, he or she is in for a 
lot of trouble.

> Threads are like the first little pig, who built a house of straw.

Possibly, but they are still implemented and perform in C much better than 
they do in Perl or similar languages.

In any case, I've done some non-cooperative multi-tasking (or maybe split-
tasking) where I assign different independent tasks to different threads (like 
solving a range of Solitaire deals by each thread solving different deals in a 
round-robin fashion) and it indeed increased the overall performance of the 
range solver on my Pentium 4 2.4GHz machine with two hyperthreads and on my 
Dual Core x86-64 laptop. I later on implemented a forking range solver, and in 
subsequent benchmarks it did not perform as well (the difference was not very 
large, but I'm not willing to throw it away either due to what I said here:
http://en.wikibooks.org/wiki/Optimizing_Code_for_Speed/Factor_Optimizations
)

On a discussion I raised on Linux-IL (the Israeli Linux mailing list), I was 
told that in order to truly benefit from multiple-cores, one has to make sure 
the individual tasks execute as closely as possible to one another, which I 
believe implies either multiple threads or alternatively a program where you 
fork without calling exec/EXECVE later and just continue execution.

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Understand what Open Source is - http://shlom.in/oss-fs

Chuck Norris can make the statement "This statement is false" a true one.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to