• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: mulithreading, dual-core
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: mulithreading, dual-core
      • From: Shawn Erickson <email@hidden>
References: 
 >mulithreading, dual-core (From: email@hidden)
 >Re: mulithreading, dual-core (From: John Daniel <email@hidden>)
 >Re: mulithreading, dual-core (From: Shawn Erickson <email@hidden>)
 >Re: mulithreading, dual-core (From: Adam Knight <email@hidden>)

  • Prev by Date: Re: mulithreading, dual-core
  • Next by Date: Re: mulithreading, dual-core
  • Previous by thread: Re: mulithreading, dual-core
  • Next by thread: Re: mulithreading, dual-core
  • Index(es):
    • Date
    • Thread