RMW
Read-modify-write (RMW) is a class of atomic instructions used in concurrent computing. In an RMW operation, a processor reads a memory location, computes a modification based on that value, and writes the result back in one indivisible step. The operation appears atomic to other threads, preventing interleaved reads or writes.
Hardware and primitives: RMW is exposed through hardware primitives such as compare-and-swap (CAS), fetch-and-add, fetch-and-sub, test-and-set,
Memory model and ordering: RMW operations are atomic with respect to a single memory location, but their
ABA problem and correctness: In RMW loops, the ABA problem can occur when a value changes from
Applications and tradeoffs: RMW is central to lock-free and wait-free data structures, such as stacks, queues,
See also: atomic operations, lock-free programming, memory model, ABA problem.