• 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: Multi-threaded help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multi-threaded help


  • Subject: Re: Multi-threaded help
  • From: John Stiles <email@hidden>
  • Date: Fri, 9 Mar 2007 12:04:49 -0800

On Mar 9, 2007, at 11:59 AM, Jan Erik Breimo wrote:


Den 9. mar. 2007 kl. 01.43 skrev arri:

On Mar 7, 2007, at 16:41 19, Erik Buck wrote:
.. it is nearly impossible to create non-trivial multi-threaded programs that are correct.

but why?

While he probably isn't, he might be alluding to the fact that C (at least not until the most recent standard) and C++ don't really support multi-threading. When you control access to some shared resource by locking a mutex or some equivalent, there's no way to specify within the standard languages that the lock-function is special and that an optimizing compiler isn't allowed to reorganize the code so that instructions originally appearing after the lock are actually executed before it. gcc probably has some compiler specific keyword that really makes this a non-issue in Cocoa, but it might at least be a minor concern for someone writing cross- platform code.


And multi-threaded code that seems to work fine on a single-core cpu, but isn't really thread-safe, is virtually bound to fail once it's moved to a multi-core cpu or multi-cpu system.

Other than that, the more I treat threads as separate process (ie. try to keep communication between threads and access to shared resources at a minimum) the more pleasant they are to work with.

Actually, sequence points in the language do guarantee that operations occur in a specified order. Optimizing compilers can do clever things, but not so clever as to move instructions outside of a lock, short of a bug in the compiler. They still need to respect the sequence points during optimization.


_______________________________________________

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


References: 
 >Re: Multi-threaded help (From: Erik Buck <email@hidden>)
 >Re: Multi-threaded help (From: Emiel Lensink <email@hidden>)
 >Re: Multi-threaded help (From: John Stiles <email@hidden>)
 >Re: Multi-threaded help (From: Shawn Erickson <email@hidden>)
 >Re: Multi-threaded help (From: arri <email@hidden>)
 >Re: Multi-threaded help (From: Jan Erik Breimo <email@hidden>)

  • Prev by Date: Re: Multi-threaded help
  • Next by Date: CoreData Questions: Solved
  • Previous by thread: Re: Multi-threaded help
  • Next by thread: Re: Multi-threaded help
  • Index(es):
    • Date
    • Thread