compare_exchange
is not a read-modify-write operationSection: 32.5.8.2 [atomics.types.operations] Status: Resolved Submitter: Alisdair Meredith Opened: 2009-03-12 Last modified: 2016-01-28
Priority: Not Prioritized
View other active issues in [atomics.types.operations].
View all other issues in [atomics.types.operations].
View all issues with Resolved status.
Discussion:
Addresses US 91 [CD1]
It is unclear whether or not a failed compare_exchange
is a RMW operation
(as used in 6.9.2 [intro.multithread]).
Suggested solution:
Make failing compare_exchange
operations not be RMW.
[ Anthony Williams adds: ]
In 32.5.8.2 [atomics.types.operations] p18 it says that "These operations are atomic read-modify-write operations" (final sentence). This is overly restrictive on the implementations of
compare_exchange_weak
andcompare_exchange_strong
on platforms without a native CAS instruction.
[ Summit: ]
Group agrees with the resolution as proposed by Anthony Williams in the attached note.
[ Batavia (2009-05): ]
We recommend the proposed resolution be reviewed by members of the Concurrency Subgroup.
[ 2009-07 post-Frankfurt: ]
This is likely to be addressed by Lawrence's upcoming paper. He will adopt the proposed resolution.
[ 2009-08-17 Handled by N2925. ]
[ 2009-10 Santa Cruz: ]
NAD EditorialResolved. Addressed by N2992.
Proposed resolution:
Change 32.5.8.2 [atomics.types.operations] p18:
-18- Effects: Atomically, compares the value pointed to by
object
or bythis
for equality with that inexpected
, and if true, replaces the value pointed to byobject
or bythis
with desired, and if false, updates the value inexpected
with the value pointed to byobject
or bythis
. Further, if the comparison is true, memory is affected according to the value ofsuccess
, and if the comparison is false, memory is affected according to the value offailure
. When only onememory_order
argument is supplied, the value ofsuccess
isorder
, and the value offailure
isorder
except that a value ofmemory_order_acq_rel
shall be replaced by the valuememory_order_acquire
and a value ofmemory_order_release
shall be replaced by the valuememory_order_relaxed
. If the comparison istrue
,Tthese operations are atomic read-modify-write operations (1.10). If the comparison isfalse
, these operations are atomic load operations.