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

Nick Maclaren nmm1 at cus.cam.ac.uk
Mon Feb 27 15:41:26 GMT 2006


David Abrahams <dave at boost-consulting.com> wrote:
>
> Which of the two approaches above is indicated by "that approach" is
> ambiguous, so I'm a bit more confused than youare.

I am not sure you are :-)  Opinions are so mixed that I have several!

> > While I agree with 90% of that, and it is obvious that any action
> > on atomic objects can equally well be implemented by operations
> > or library calls
>
> It is not obvious to me that it would be "equally good" syntactically.

Well, given the way that C++ maps actions to function calls and
provides syntactic sugar for function calls, it can't be very
different.

> Forbids removing what qualification?  We don't have such qualification
> in C++ today AFAIK.

Oops :-)

> And why is it essential that qualification can't be explicitly cast
> away?  You can cast everything /else/ away in C++.

For two reasons.  Firstly, the implementation may need to do something
different for atomic and non-atomic objects.  Secondly, the non-atomic
ones may not be safe immediately adjacent to an atomic datum, which
causes trouble with arrays of atomic if it can be cast away.

> Really?  You mean Foo const and Foo need not have the same size?

That's what those sections say :-)  Actually, I don't think that it
can be done (because you can cast away qualifiers), but I am not
entirely sure of it.

> If you mean dynamic allocation, I don't see the relevance.  AFAICT,
> all it needs is maximal alignment, which malloc already has.

What if it needs to go into an uncached memory segment?  That is
needed on some architectures.


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