|
| ▲ | hrmtst93837 3 hours ago | parent | next [-] |
| That's backwards: in C++, a release store to head_ and an acquire load of that same atomic do order the prior buffer_ write, even though the data and index live in different locations, so the consumer that sees the new head can't legally see an older value for that slot unless something else is racing on it seperately. If this is broken, the bug is elsewhere. |
|
| ▲ | loeg 6 hours ago | parent | prev | next [-] |
| > There's no relationship between the two written variables. Stores to the two are independent and can be reordered. The aq/rel applies to the index, not to the unrelated non-atomic buffer located near the index. No, this is incorrect. If you think there's no relationship, you don't understand "release" semantics. https://en.cppreference.com/w/cpp/atomic/memory_order.html > A store operation with this memory order performs the release operation: no reads or writes in the current thread can be reordered after this store. |
|
| ▲ | judofyr 6 hours ago | parent | prev | next [-] |
| This is just wrong. See https://en.cppreference.com/w/cpp/atomic/memory_order.html. Emphasis mine: > A store operation with this memory order performs the release operation: no reads or writes in the current thread can be reordered after this store. All writes in the current thread are visible in other threads that acquire the same atomic variable (see Release-Acquire ordering below) and writes that carry a dependency into the atomic variable become visible in other threads that consume the same atomic (see Release-Consume ordering below). |
|
| ▲ | blacklion 6 hours ago | parent | prev [-] |
| write with release semantic cannot be reordered with any other writes, dependent or not. Relaxed atomic writes can be reordered in any way. |
| |
| ▲ | loeg 6 hours ago | parent [-] | | > write with release semantic cannot be reordered with any other writes, dependent or not. To quibble a little bit: later program-order writes CAN be reordered before release writes. But earlier program-order writes may not be reordered after release writes. > Relaxed atomic writes can be reordered in any way. To quibble a little bit: they can't be reordered with other operations on the same variable. | | |
| ▲ | blacklion 5 hours ago | parent [-] | | Yep, you are right, more precise, and precision is very important in this topic. I stand corrected. |
|
|