Home Knowledge Base Memory Consistency Models

Memory Consistency Models define the contractual rules governing the order in which memory operations (loads and stores) from different threads become visible to each other — where the choice between strict sequential consistency and relaxed models (TSO, release-acquire, relaxed) determines both the correctness guarantees available to the programmer and the performance optimizations the hardware and compiler are permitted to make.

Why Consistency Models Exist

Modern processors reorder memory operations for performance: store buffers delay writes, out-of-order execution completes loads before earlier stores, and compilers rearrange memory accesses. Without a model defining which reorderings are legal, multi-threaded programs would have unpredictable behavior across different hardware.

Key Models (Strongest to Weakest)

Practical Impact

// Thread 1           // Thread 2
data = 42;            while (!ready);  
ready = true;         print(data);     // Must print 42?

Under SC: Guaranteed to print 42. Under Relaxed: May print 0 (stale data) because the compiler or hardware may reorder data = 42 after ready = true, or Thread 2 may see ready before data propagates. Under Release-Acquire: If ready is stored with release and loaded with acquire, guaranteed to print 42.

Fences and Barriers

Memory Consistency Models are the invisible contract between hardware designers and software developers — defining the boundary between optimizations the hardware may perform silently and ordering guarantees the programmer can rely upon for correct multi-threaded execution.

memory consistency modelsequential consistencyrelaxed consistencyacquire release semanticsmemory ordering parallel

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.