[cpp-threads] seq_cst compare_exchange and store-load fencing

Paul E. McKenney paulmck at linux.vnet.ibm.com
Thu Jan 15 01:26:41 GMT 2009


On Mon, Jan 12, 2009 at 09:27:43PM -0800, Hans Boehm wrote:
> [After finally catching up with this thread.]
>
> I agree with the general conclusions and the fact that clarification would 
> help here.  I think Doug earlier suggested renaming "seq_cst" to something 
> like "maintain_sequential_consistency".  But just adding notes is probably
> much less painful at this stage.  I would favor putting the notes into
> the atomics section, together with the definition of memory_order_seq_cst.
>
> It sounds like we need a library issue?

How about the following?  If we are keeping hands off of section
1.10, then my suggestion about adding the definition of SC in 1.10
is inoperative.

							Thanx, Paul

ISSUE:  Interaction between SC and non-SC atomics needs clarification

Discussion:

	Although n2800 accurately specifies the C++ memory model,
	experience has shown that there is potential for confusion about
	the interactions between SC and non-SC atomics, as discussed
	via email on the cpp-threads list.  In the course of those
	discussions, Alexander Terekhov suggested that three clarifying
	notes be added.  Alexander's notes, slightly edited, are shown
	in the proposed resolution.

Proposed Resolution:

A.	Add the following three notes to the end of 29.1p2 (shown as
	separate paragraphs here for clarity):

	[/Note:/ Nothing requires that sequentially consistent operations
	[memory_order_seq_cst] be ordered with respect to non-sequentially
	consistent operations except as required by acquire, consume,
	and release semantics.1]. -- /end note/]

	[/Note:/ If you want sequentially consistent results, use
	sequential consistency everywhere.  On the other hand, if you
	want to use optimizations mixing sequentially consistent and
	non-sequentially consistent atomics, make sure that you understand
	the actual guarantees that sequential consistency provides. --
	/end note/]

	[/Note:/ If you want sequentially consistent operations to
	be guaranteed ordered with respect to non-seq_cst operations,
	use atomic_thread_fence(seq_cst) [see 29.6] to segregate the
	operations. -- /end note]



More information about the cpp-threads mailing list