The reordering problem: compilers and CPUs lie
The code you write is not the code that executes. Both the compiler and the CPU reorder instructions freely, as long as the reordering is invisible to a single thread. The moment you have two threads, what looks invisible locally becomes catastrophically visible globally.
Compiler example: a store to ready = true may be hoisted above the write to data if the compiler sees no dependency. CPU example: store-buffer forwarding on x86 means a core may read its own recent write before other cores see it; on ARM and POWER, even store order between two cores is not guaranteed.
Why? Performance. Reordering allows out-of-order execution, pipeline saturation, and cache-line prefetching. Modern CPUs can sustain 3–6 instructions per cycle precisely because they're free to reorder.
The implication: you cannot reason about concurrent programs by reading C or Python source. You must think in terms of the memory model the language or hardware guarantees.
