Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: multithreading, dual-core



on 2/26/07 1:48 PM, Chris Hanson at <email@hidden> wrote:
> On Feb 26, 2007, at 10:30 AM, George Warner wrote:
>> On Sun, 25 Feb 2007 11:37:21 -0800, Shawn Erickson <email@hidden>
>> wrote:
>>> Often it is the algorithm and not the locking overhead that is a problem.
>> 
>> One "newbie" mistake I often see is over locking. The fastest and least
>> likely lock to deadlock is the ones you can completely avoid. Google
>> "lockless programming".
> 
>> If at all possible use atomic operators (great for ref-count modifiers);
>> then spin-locks and only as a last resort conditional mutexes.
> 
> I'd say exactly the opposite:  One newbie mistake that I often see is not
> locking sufficiently, and trying to optimize away synchronization before
> ensuring correctness.

I guess the consensus here is that an experienced MT/SMP programmer neither
under or over locks.  ;-)

Under locking would fail to properly protect your data and over locking
would protect your data but at an increased risk of deadlocks and at a
greater performance penalty.

If I might expand on my earlier opinion: It's a newbie mistake to over lock
(because the only thing I remember from the class in college was that you
have to use a lock to protect your data when it might be accessed via
multiple threads...) and an intermediate mistake to under lock (because I
read this internet article about how to avoid deadlocks by avoiding
locks...).

YMMV. ;-)

-- 
Enjoy,
George Warner,
Schizophrenic Optimization Scientist
Apple Developer Technical Support (DTS)


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/xcode-users/email@hidden

This email sent to email@hidden

References: 
 >Re: multithreading, dual-core (From: Chris Hanson <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.