[cpp-threads] Failed compare-and-swap
Lawrence Crowl
Lawrence at Crowl.org
Thu Aug 2 19:33:15 BST 2007
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.
On 7/31/07, Lawrence Crowl <Lawrence at crowl.org> wrote:
> Just to be clear on the evolving specification:
>
> extern "C"
> bool atomic_compare_swap_explicit(
> volatile atomic_int* the_atomic,
> int* the_old_value,
> int the_new_value,
> memory_order failure_order,
> memory_order success_order );
>
> bool atomic_int::compare_swap(
> int& the_old_value,
> int the_new_value,
> memory_order failure_order = memory_order_seq_cst,
> memory_order success_order = memory_order_seq_cst );
>
> The failure_order parameter applies when the write does not happen,
> and may use the "read" subset of memory_order (relaxed, acquire,
> seq_cst).
>
> The success_order parameter applies when the write does happen (and
> hence the read also happened and may use any of the memory_order
> values.
>
> (I chose the parameter order because one is more likely to weaken
> failure_order than the success_order.)
>
> In the event of failure, there is still value dependence on the load.
--
Lawrence Crowl
More information about the cpp-threads
mailing list