This is a common atomic instruction that exists on many CPU architectures. (x86: cmpxchg
, SPARC: cas
). It compares a value in memory with a value in a register, and if they match, overwrites the value in memory with a third value. If successful, the operation sets a status flag that can be used for branching. This can be used to efficiently implement spinlocks.
See also Atomic instruction and Spinlock.
18.216.27.251