expression

Linearization point: successful conditional state change

A linearizable operation appears to take effect at one point between its call and return, consistently with real-time precedence. A successful compare-exchange can be a candidate linearization point for a single-word update. More complex algorithms need a proof that their full abstract behavior matches the specification. Expected stdout (not executed): true false 1 Common mistake: Assuming every multi-step operation is linearizable because one internal operation is atomic.

Formal Syntax & Structure

rust syntaxrust
compare_exchange(expected, replacement, success, failure)

Working Example

Example Snippetrust
fn main() {    use std::sync::atomic::{AtomicUsize, Ordering::Relaxed};    let state = AtomicUsize::new(0);    let first = state.compare_exchange(0, 1, Relaxed, Relaxed);    let second = state.compare_exchange(0, 2, Relaxed, Relaxed);    println!("{} {} {}", first.is_ok(), second.is_ok(), state.load(Relaxed));}
Rust Reference