Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardC++the C++ memory modelSingle-choice MCQ

Consider Dekker-style code: each thread stores 1 to its own flag then loads the other's flag. With `memory_order_seq_cst` on all four operations, can both loads read 0?

std::atomic<int> x{0}, y{0}; // Thread 1 x.store(1, std::memory_order_seq_cst); int r1 = y.load(std::memory_order_seq_cst); // Thread 2 y.store(1, std::memory_order_seq_cst); int r2 = x.load(std::memory_order_seq_cst);