read/write volatile
read/write volatile
Posted Jan 10, 2026 21:12 UTC (Sat) by willmo (subscriber, #82093)In reply to: read/write volatile by NYKevin
Parent article: READ_ONCE(), WRITE_ONCE(), but not for Rust
I think it’s a third meaning of “implement”, as implied by comex’s adjacent comment: when the target hardware doesn’t natively support the desired C/C++ atomic operation (e.g. it lacks even an appropriate CAS to implement a RMW), the compiler must compile it to use a global lock. This is certainly not applicable to common data types on modern x86, ARM, etc.
> If you take a global lock, then there are two different memory locations in play (lock and payload), so your parenthetical above already tells us that the lock is ineffective (at protecting against against un-fenced relaxed atomics on either the lock or the payload).
In this case, the compiler would need to compile un-fenced relaxed atomics so that they take the global lock. That’s what plugwash meant.
