• 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: Techniques for thread communication
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Techniques for thread communication


  • Subject: Re: Techniques for thread communication
  • From: "Alastair J.Houghton" <email@hidden>
  • Date: Tue, 9 Sep 2003 11:37:07 +0100

On Tuesday, September 9, 2003, at 11:13 am, Peter Robinson wrote:

Chris Purcell <email@hidden> wrote:

Only if intResult is not word-aligned: word-aligned reads and writes
are atomic on PPC and Intel alike.

That's good. AIUI int instance variables will normally be word-aligned.
But what about the same accessor pattern for the following instance
variables:

@interface SomeClass
{
short alignedShort, unalignedShort;
BOOL alignedBOOL, unalignedBOOL;
}
@end

I'm guessing (and hoping) that even though BOOLs and shorts have smaller
alignment, the same accessors are still thread safe in some sense.

The PPC PEM says that accesses to 8-bit values are atomic at 8-bit alignments, 16-bit values at 16-bit alignments and 32-bit values at 32-bit alignments. It makes no guarantees as regards other accesses, and even notes that double-precision (64-bit) floating point memory accesses are *not* guaranteed to be atomic on 32-bit implementations even when accessing 64-bit aligned memory.

You do have to be a bit careful when considering whether a C statement is atomic because PPC and most other RISCs are load/store (i.e. they cannot work directly on memory), so for example

intResult++

*isn't* an atomic operation.

Kind regards,

Alastair.
_______________________________________________
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.

References: 
 >Re: Techniques for thread communication (From: email@hidden (Peter Robinson))

  • Prev by Date: anything for cocoa other than java or obj-c?
  • Next by Date: Re: anything for cocoa other than java or obj-c?
  • Previous by thread: Re: Techniques for thread communication
  • Next by thread: NSURLResponse expectedContentLength is -1
  • Index(es):
    • Date
    • Thread