Re: Problem on dual-processor Macs
Re: Problem on dual-processor Macs
- Subject: Re: Problem on dual-processor Macs
- From: Kaelin Colclasure <email@hidden>
- Date: Thu, 25 Sep 2003 06:27:11 -0700
On Thursday, September 25, 2003, at 02:47 AM, Tim Hewett wrote:
>
These indexes are C 'int' data types, so are signed 32-bit
>
integers at the CPU instruction level. I would expect that
>
incrementing a 32-bit integer to be an atomic operation,
... And you would be mistaken. :-) While the PPC ISA no doubt has an
operation (or sequence of operations) that accomplishes an "atomic
increment", your C compiler is not going to generate code for ++i (or
any variation thereof) that uses it.
If you need this code to be portable, you're going to be stuck with
using OS-level interprocess synchronization support of one kind or
another (and as a consequence you're going to see a substantial
performance cost).
If easy portability can take a back seat to performance, then you can
use gcc's inline assembler to write functions which will use the
correct PPC instruction(s) to accomplish this task. Or better still,
use Google to sleuth out one of the scores of implementations that no
doubt are floating around out there in various open source projects.
Here is a search hit to get you started:
http://archives.postgresql.org/pgsql-bugs/1997-10/msg00020.php
Additional hint: This operation is generically classified as a "test
and set" instruction (just in case you need to do more Googling).
HTH,
-- Kaelin
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.