Re:The x86 architecture is the weirdo, part 2
by toast0 on Friday April 22, 2022 @12:08PM
(#31123444)
> Fair point, but I'd qualify that OOO is only observable for racy programs.
I mean, you're basically saying that it's only observable if you care to observe it.
Re:The x86 architecture is the weirdo, part 2
by zozbot234 on Friday April 22, 2022 @11:16AM
(#31122641)
Rust has atomic types that can observe races. Such "racy" code is useful because some concurrent code doesn't need the strictest guarantees (sequential consistency). Though, compared to C, Rust does not use the "Consume" memory ordering because so far it has turned out to be ill-defined.
Re:The x86 architecture is the weirdo, part 2
by titzer on Friday April 22, 2022 @11:39AM
(#31122967)
AFAICT those can't observe OOO of CPUs, just nondeterminism from interleavings different threads. I.e. they will give you sequential consistency unless you have other, worse races.
Re:The x86 architecture is the weirdo, part 2
by zozbot234 on Friday April 22, 2022 @11:53AM
(#31123213)
Sequential consistency is absolutely optional, there are several other possible memory orderings that are far weaker. When programs involve multiple atomic locations concurrently, atomicity is only preserved at each separate location.
Generally, most programmers shouldn't need to be reasoning about OOO or memory order and be using fences. Rather, they should use libraries that are written by experts that use extra-lingual mechanisms (like compare-swap or fences) to guarantee a higher contract.