Jun 15, 2017

[C++][note] Can Reordering of Release/Acquire Operations Introduce Deadlock?

preshing's article:
Can Reordering of Release/Acquire Operations Introduce Deadlock?

C++17 working draft:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf

excerpt:
N4659, section 4.7.2:18 states:
An implementation should ensure that the last value (in modification order) assigned by an atomic or synchronization operation will become visible to all other threads in a finite period of time.


Refer to this note:
http://vsdmars.blogspot.in/2015/10/c-concurrent-notenote-ch5-study-note.html
RELAXED ORDERING:
Operations on atomic types performed with relaxed ordering don’t participate in synchronizes-with relationships.

Operations on the same variable within a single
thread still obey happens-before relationships, but there’s almost no requirement on ordering relative to other threads.

The only requirement is that accesses to a single
atomic variable from the same thread can’t be reordered; once a given thread has seen a particular value of an atomic variable, a subsequent read by that thread can’t retrieve an earlier value of the variable.

1. 同一個thread仍有同一個 variable 的 happen before relationship
2. 同一個thread同一個variable不能被either compiler reordered or memory reordering.
3. 同一個thread但不同variable,compiler仍能做reordering!!

----
RMW operations had to see the latest value in the object's modification order;
even 32.4:11 in the standard says so, quote:
Atomic read-modify-write operations shall always read the last value (in the modification order) written before the write associated with the read-modify-write operation.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.