I understand that two operations interlockedfor one variable are ordered. Other than this, is there any ordering guarantee for operations interlockedfor two different variables?
In C ++, we have semantics memory_order_seq_cstthat ensure that
29.3 / 3
All memory_order_seq_cst should have one general order S in accordance with the order “occurs before” and change orders for all affected locations, ...
EDIT: if we limit the discussion to x86, there is a memory model called x86-TSO that defines the order between two LOCKprefix operations.
To execute the LOCKd command, the thread must first obtain a global lock. At the end of the instruction, it flushes its storage buffer and releases the lock. While the lock is held by one thread, no other thread can read.
According to the above rule, two lock operations will be globally ordered on x86.
source
share