Re: Multi-threaded help
Re: Multi-threaded help
- Subject: Re: Multi-threaded help
- From: "Dave Camp" <email@hidden>
- Date: Fri, 9 Mar 2007 18:28:26 -0800 (PST)
- Importance: Normal
Chris sent this off list, but I hope he doesn't mind my sending to the
list as the link he provided is a good read.
On Fri, March 9, 2007 4:53 pm, Chris Suter wrote:
>> Mmm. No. If that were true, most of the threaded code in the world
>> would simply not work. The compiler can't just change the order of
>> execution of calls to functions like [NSLock lock] or
>> pthread_mutex_lock(). You don't need to do anything special to get
>> locks and semaphores to work as expected. If your threading model
>> is not working it's most likely due to a design flaw in your
>> software, not the compiler.
>>
>> For anyone delving into threads for the first time, I'd highly
>> recommend the Pthreads Programmng book from OReilly. It's a good
>> read regardless of the language or framework you are using.
>>
>> Dave
>
> Hi Dave,
>
> You might want to read this (if you haven't already):
>
> http://www.hpl.hp.com/techreports/2004/HPL-2004-209.ps
>
> Kind regards,
>
> Chris
That is an interesting paper from HP. Definitely some good insights into
the intricate problems facing today's highly optimizing compilers and
modern multi-threaded coding.
The problem is, that paper would seem to suggest that pthreads and
C/C++/Obj-C potentially generates a lot of bad code, depending on your
compiler (oddly, the paper doesn't name what compilers were tested). The
same sorts of issues raised earlier in this thread.
And yet somehow Mac OS X, Linux, and other POSIX platforms have managed to
run without widespread corruption, and that documentation of these
important perils is missing from all of Apple's developer documentation
and example code and the pthreads documentation (although I will admit to
not having read the pthreads docs from front to back in a few years).
To be sure, the Cocoa docs for NSThread and NSLock don't mention anything
about this.
Either we have been very lucky for the last few decades, or gcc does a
good job of managing the problem.
Dave
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden