Re: Multi-threaded help
Re: Multi-threaded help
- Subject: Re: Multi-threaded help
- From: Jan Erik Breimo <email@hidden>
- Date: Fri, 09 Mar 2007 20:59:12 +0100
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.
--
Jan Erik
_______________________________________________
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