[cpp-threads] modes
Peter Dimov
pdimov at mmltd.net
Sat May 7 17:13:14 BST 2005
Doug Lea wrote:
> The minimal list seems to be along the lines of
> read-with-acquire
> write-with-release
> write-preserving-order
> CAS-with-acquire-release
> CAS-with-release
> (plus the default ordinary-read and ordinary-write)
>
> We'd still need to spell out the details of exactly what acquire,
> release, and write-ordering mean, especially wrt the highly
> inconvenient sequence-point wording of the rest of the C++ spec.
The good thing about acquire and release is that a write-with-release on a
memory location X happens-before a subsequent load-with-acquire on the same
memory location. :-)
But there are two problems with the above set.
The first problem is that it's missing unconstrained atomics. Ordinary reads
and writes are not atomic or race-resistant, and there is no unconstrained
CAS in the set (and by extension, no unconstrained read-modify-writes.) This
will penalize reference counting by up to 100% because it doesn't need
synchronization on increment, only on decrement.
The second problem is that finer-grained constraints can eliminate some of
the barriers. For example, read with acquire is
read
#LoadLoad | #LoadStore
but read with hoist-load barrier is
read
#LoadLoad
and a compiler is unable to exploit this without being explicitly told that
only loads need to be constrained.
However finer-grained constraints seem unexpressible in a sequential
consistency or a happens-before model. Or if they are expressible, I haven't
figured out how.
More information about the cpp-threads
mailing list