Memory Model
A memory model defines the visibility and ordering guarantees for reads and writes across threads — the foundation of concurrent correctness.
Purpose
Understand the reordering and visibility rules of memory operations under multithreading, and write correct concurrent code.
Mechanism
Sequential consistency (SC): all threads see one unified order. Acquire-release: writes before the release become visible after the acquire. Relaxed: atomicity only, no ordering guarantees. Java/JS/C++ each specify their own memory model.
Use cases
- Concurrent programming
- Lock-free algorithms
- Language specifications