Hard
Two readers observing two independent release stores
Four threads run w1, w2, r1, and r2 once each, concurrently. Is the outcome a == 1, b == 0, c == 1, d == 0 allowed? In that outcome r1 saw x's store but not y's, while r2 saw y's store but not x's.
main.cpp
std::atomic<int> x{0}, y{0};
int a, b, c, d;
void w1() { x.store(1, std::memory_order_release); }
void w2() { y.store(1, std::memory_order_release); }
void r1() {
a = x.load(std::memory_order_acquire);
b = y.load(std::memory_order_acquire);
}
void r2() {
c = y.load(std::memory_order_acquire);
d = x.load(std::memory_order_acquire);
}51 of 51 in Concurrency