3 ms·
Does Rust handle anything with memory barriers? I can handle concurrency, interrupt handlers, etc, but memory barriers always trouble me.
by fullstop 6y ago
Does Rust handle anything with memory barriers? I can handle concurrency, interrupt handlers, etc, but memory barriers always trouble me.
- steveklabnik 6y agoIt will force your code to be memory safe, but it can't enforce that you have the correct semantics. https://doc.rust-lang.org/std/sync/atomic/fn.fence.html https://doc.rust-lang.org/std/sync/atomic/fn.fence.html exists, but Rust can't force you to say, use the correct ordering.
- fullstop 6y agoRight, so no different than C in this regard.
- comex 6y agoReally, you should rarely be using raw memory barriers even in C, IMO. The C11/C++11 atomics model (which Rust also uses) is substantially nicer. Though, unfortunately, still extremely tricky to get right.
- fullstop 6y agoThe only time that I ever had to worry about that was when writing drivers for the Linux kernel.