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

Nick Maclaren nmm1 at cus.cam.ac.uk
Thu Mar 2 21:35:45 GMT 2006


"Peter Dimov" <pdimov at mmltd.net> wrote:
>
> >> 2. making "atomic" a (non cv-) qualifier that can't be added
> >> implicitly, can be casted away relatively safely, and can possibly
> >> be added via a cast relatively unsafely.
> >
> > The weakness of that is you then have to define ordering semantics
> > between atomic and non-atomic accesses to the same object.  It
> > doesn't help if you forbid it, because you have to defined WHAT
> > you are forbidding.
> 
> It seems to me that we have to define it in either case, because we want to 
> allow races if
> 
> 1. both operations are reads
> 2. both operations are atomics
> 
> and disallow everything else. So outlawing write+read and write+write will 
> automatically take care of atomic_write+read, write+atomic_read, 
> atomic_write+write. 

Not if we use Hans Boehm's memory model.  The rules for how accesses
can be reordered are different for atomic and non-atomic ones, but
(as his paper standards at present), the assumption is that the two
are entirely distinct classes of object.  It adds a considerable
amount of complexity if they can be the same.


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