m-ou-se / rust-atomics-and-locks

Code examples, data structures, and links from my book, Rust Atomics and Locks.
Other
1.33k stars 120 forks source link

Question about the memory ordering of the store in the last fence example in chapter 3 #50

Open orium opened 8 months ago

orium commented 8 months ago

The content that the question is about

The store in READY: https://github.com/m-ou-se/rust-atomics-and-locks/blob/main/examples/ch3-11-fence.rs#L17

The question

The atomics in READY are only read with Relaxed ordering in line 21. Can't the store in line 17 be done with memory ordering Relaxed (instead of Release), since relaxed is enough to establish a total order between stores and loads of the same variable?