[cpp-threads] Failed compare-and-swap

Lawrence Crowl Lawrence at Crowl.org
Mon Aug 6 21:46:45 BST 2007


Lawrence Crowl wrote:
> Are there any objections to the following compare-and-swap?
> Basically, it adds another parameter specifying the memory
> synchronization for the load-only-write-did-not-happen case.

Nelson, Clark wrote:
> Are there reasonable ways on existing implementations to implement
> the full flexibility of this? It seems pretty inventive to me.

On 8/3/07, Bronek Kozicki <brok at spamcop.net> wrote:
> it struck me as well. If we replace enums with typetags (e.g.
> std::memory_order_seq_cst a'la std::nothrow ), we might define
> only small subset of valid combinations and leave the rest for
> implementators to define (if they wish so).

I view the set of memory_order not so much as space that must
be implemented, but rather as a space in which implementations
may place themselves.  That is, an implementation will still be
standard conforming if all of its atomic operations were sequentially
consistent.  That implementation will perform better if it implements
the weaker orders that make sense on the given hardware.

On the other hand, programmers desiring both good performance and
good portability will probably need to understand and use all of
the memory_order values.

-- 
Lawrence Crowl



More information about the cpp-threads mailing list