You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Quoting from the "Sequential Consistency" part of Atomics:
Intuitively, a sequentially consistent operation cannot be reordered: all accesses on one thread that happen before and after a SeqCst access stay before and after it.
I believe this is wrong, as it states that "all accesses" (which presumably includes data and weaker atomic accesses) cannot be reordered past SeqCst access.
Only other SeqCst accesses cannot be reordered with SeqCst access.
For example, data (and relaxed atomic) accesses can be reordered:
before SeqCst stores
after SeqCst loads
So, "all accesses" should be replaced with "all SeqCst accesses".
The strongest memory ordering is sequentially consistent ordering: Ordering::SeqCst. It includes all the guarantees of acquire ordering (for loads) and release ordering (for stores), and also guarantees a globally consistent order of operations.
This means that every single operation using SeqCst ordering within a program is part of a single total order that all threads agree on. This total order is consistent with the total modification order of each individual variable.
Myth: Sequentially consistent memory ordering can be used for a "release-load" or an "acquire-store."
While SeqCst can stand in for Acquire or Release, it is not a way to somehow create an acquire-store or release-load. Those remain nonexistent. Release only applies to store operations, and acquire only to load operations.
For example, a Release-store does not form any release-acquire relationship with a SeqCst-store. If you need them to be part of a globally consistent order, both operations will have to use SeqCst.
The text was updated successfully, but these errors were encountered:
Quoting from the "Sequential Consistency" part of Atomics:
I believe this is wrong, as it states that "all accesses" (which presumably includes data and weaker atomic accesses) cannot be reordered past SeqCst access.
Only other SeqCst accesses cannot be reordered with SeqCst access.
For example, data (and relaxed atomic) accesses can be reordered:
So, "all accesses" should be replaced with "all SeqCst accesses".
From C++ standard (page 1525, par 7):
From Rust Atomics and Locks
The text was updated successfully, but these errors were encountered: