Re: mulithreading, dual-core
Re: mulithreading, dual-core
- Subject: Re: mulithreading, dual-core
- From: John Daniel <email@hidden>
- Date: Sun, 25 Feb 2007 14:12:11 -0600
On Feb 25, 2007, at 12:19 PM, Adam Knight wrote:
And then your code may wind up being orders of magnitude slower.
This particular bit doesn't have to be fast. It just has to keep
multiple threads from blowing past the mutex lock, getting deep into
the AppKit, and crashing.
The following bit is a good discussion of what the compiler's going
to do in various multithreading cases and offers a few ideas to
getting past using full locks.
http://ridiculousfish.com/blog/archives/2007/02/17/barrier/
Here is a better one: http://www.ddj.com/dept/cpp/184403766
I'm afraid I'm going to have to take Andrei Alexandrescu's word over
that of the author of the ridiculousfish blog.
On Feb 25, 2007, at 10:02 AM, Shawn Erickson wrote:
On Feb 25, 2007, at 7:28 AM, John Daniel wrote:
Learn about the volatile modifier. Your code isn't going to be
just multithreaded, it will be parallel. You won't be able to get
away with just mutex locks. They will have to be volatile mutex
locks.
If you use proper locking you won't need volatile.
My thread-safe code that had its mutex locks optimized out of
existence seems to disagree with you. Once I made my mutex locks
volatile, they magically started working the way they are supposed
to. My mutex locks didn't fail until I had 8 or 9 threads running.
So, it seemed to me that while my previous code was "thread-safe", it
wasn't "multiprocessor-safe".
It is certainly possible that I've screwed up something else and just
haven't discovered that yet. But my research indicated that I really
should have been using volatile because the compiler may be making
assumptions about code that are incorrect in a multi-threaded and
parallel context.
Have a nice day:)
John
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden