https://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync-Thread 1-
y.store (20, memory_order_relaxed)
x.store (10, memory_order_relaxed)
-Thread 2-
if (x.load (memory_order_relaxed) == 10)
{
assert (y.load(memory_order_relaxed) == 20) /* assert A */
y.store (10, memory_order_relaxed)
}
-Thread 3-
if (y.load (memory_order_relaxed) == 10)
assert (x.load(memory_order_relaxed) == 10) /* assert B */
gccwiki上说,assertB是有可能fail的
搜到一个so,但两个解释我都没完全看懂
https://stackoverflow.com/questions/46065770/confused-about-atomic-class-mem
ory-order-relaxed/46066462#46066462
是说在thread2里的y.store(10)也有可能发生在thread1的x.store(10)之前是么
--
FROM 171.83.8.*