Re: Accessing array in thread safe way
Re: Accessing array in thread safe way
- Subject: Re: Accessing array in thread safe way
- From: Per Bull Holmen <email@hidden>
- Date: Thu, 08 Mar 2012 16:46:41 +0100
Den 23:55 7. mars 2012 skrev Don Quixote de la Mancha
<email@hidden> følgende:
> If you possibly can replace locking algorithms with what are commonly but incorrectly called lock free algorithms. They use Atomic Arithmetic Primitives provided by the CPU Instruction Set Archetector to manage very short term locks on single words of memory.
Lock-free algorithms are cool, but keep in mind that they can be hard
to implement, so you have to know what you're doing. Once you have
forgotten to think of a possible scheduling sequence that might
corrupt your data, you have introduced very subtle bugs that can be
very hard to track down. If you only stick to well-known algorithms
that are well tested, you should be OK, I think. But remember to
analyze the whole structure of the app to determine if that algorithm,
used the way you intend to use it, does really make it thread safe. I
guess this last bit is true whether you use locks or not.
To see a list of atomic primitives for OS X apps, start terminal and type
man atomic<enter>
Per
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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