Boost logo

Boost :

Subject: Re: [boost] Help needed for shared_ptr issue on iPad2 (dualcore ARM)
From: Peter Dimov (pdimov_at_[hidden])
Date: 2011-03-28 12:39:31


Phil Endecott wrote:

> First let me say that the "right way" to fix this is surely to get
> Boost.Atomic finished and to use that as the basis of shared_ptr.

Maybe, but until it is, we still need to fix things somehow.

> I've contributed ARM code for Boost.Atomic that knows about the different
> architecture versions and will use ldrex/strex on ARMv7 (though it needs
> some attention from someone who knows more than I do about memory
> barriers, and it has had very little testing).

Where can I see this code? How do you detect the ARMv7 architecture to
enable ldrex/strex use?

> In the meantime, my understanding is that SWP is "deprecated" in ARMv7 -
> except that it is a peculiarly strong kind of deprecation where you have
> to turn on a bit in a control register to enable it.

Yes, it's deprecated, but it still 'should' work, or perhaps fail, but
judging by the bug report in the ticket, it seems that it works but is
non-atomic.

> One other issue is that even when enabled, SWP might not have the required
> memory barrier semantics on the multi-processor systems, i.e. you might
> need to put explicit barrier instructions either side of it.

As far as I know, the official semantics of SWP on newer architectures are
that it works but is inefficient because it locks the bus. Who knows what it
does on the Apple CPU though.

> > how can we detect support for __sync intrinsics and use them.
>
> I believe that there is a macro something like
> __GCC_HAVE_SYNC_COMPARE_AND_SWAP__.

There should be __GCC_HAVE_COMPARE_AND_SWAP_4, but I'm not sure if it's
actually defined by the whatever compiler people use for iOS development.
:-)


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk