[cpp-threads] RE: volatile, memory models, threads

Nick Maclaren nmm1 at cus.cam.ac.uk
Thu Mar 2 11:56:06 GMT 2006


Ben Hutchings <ben at decadentplace.org.uk> wrote:
>
> Since the 68000 had a 16-bit bus, older m68k ABIs require only 16-bit
> alignment of 32-bit values, and later m68k processors accept that.
> However, atomic access to a 32-bit value on these later processors
> requires 32-bit alignment (or at least that the entire value is in a
> single cache line).
>
> All i386 ABIs, AFAIK, use 64-bit doubles but only require 32-bit
> alignment for them.  Again this means it would be necessary to increase
> alignment where atomic access is needed.

Well, yes, and I can give other examples.  But those really only apply
to running existing binaries, or new code that will be called with data
provided from existing binaries.  If we are talking about an entirely
new facility, then it is what is allowed in new code (i.e. languages)
that matters.

Now, this does interact with the cv-qualifier question because, if
atomic is something that can be added to an lvalue (as a qualifier or
by calling a function), then previously compiled code can allocate
misaligned data and call new code that attempts to act atomically.

For that and MANY other reasons, I regard it as a terrible idea to
allow an atomic library to act on data that was not allocated for
atomic use.


Regards,
Nick Maclaren,
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QH, England.
Email:  nmm1 at cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679



More information about the cpp-threads mailing list