[Day20] Read Rust Atomics and Locks — The Memory Model

By Mara Bos

R4 Cheng
Jun 30, 2023

From: The Memory Model

To: Example: The Memory Model

At Topics: Chapter 3. Memory Ordering

Notes

Q: Why we need the memory model?

A: The different memory ordering options have a strict formal definition. To avoid being tied to the specifics of particular processor architectures, it is defined based on an abstract memory model.

  • Rust’s memory model, which is mostly copied from C++
  • To prevent data races and undefined behavior, Rust’s memory model encourages the use of atomic operations for concurrent access to shared variables. Atomic operations provide synchronization mechanisms that ensure safe and predictable behavior when multiple threads access the same variable concurrently.

--

--

R4 Cheng
R4 Cheng

Written by R4 Cheng

「0」が過去で「1」が未来「今」は何処にもない

No responses yet