Memory ordering – happens-before and synchronizes-with
Each CPU architecture treats memory ordering—the dependency relationships between loads and stores—differently. We discussed this in detail in Chapter 1, Preliminaries – Machine Architecture and Getting Started with Rust. Suffice it to say here in summary, x86 is a strongly-ordered architecture; stores by some thread will be seen by all other threads in the order they were performed. ARM, meanwhile, is a weakly-ordered architecture with data-dependency; loads and stores may be re-ordered in any fashion excepting those that would violate the behavior of a single, isolated thread, and, if a load depends on the results of a previous load, you are guaranteed that the previous load will occur rather than be cached. Rust exposes its own model of memory ordering to the programmer, abstracting away these details. Our programs must, then, be correct according to Rust's model, and we must trust rustc
to interpret this correctly for our target...