Maybe my definition of a lock is too loose, but aren't atomic operations basically per-variable locks? Aren't you basically saying "no one can have access to this variable until I am done updating it"?
ferozenaina
Atomic operations are typically implemented in the hardware architecture itself. At the abstraction level, it is analogous to having a per-variable lock.
Capturing and releasing a lock or mutex for a variable is a software operation and is more expensive compared to atomic operations.
carnegieigenrac
I'd define a lock as a piece of memory designated for preventing data races to a particular variable. Atomic operations don't require any additional places in memory to work.
Maybe my definition of a lock is too loose, but aren't atomic operations basically per-variable locks? Aren't you basically saying "no one can have access to this variable until I am done updating it"?
Atomic operations are typically implemented in the hardware architecture itself. At the abstraction level, it is analogous to having a per-variable lock.
Capturing and releasing a lock or mutex for a variable is a software operation and is more expensive compared to atomic operations.
I'd define a lock as a piece of memory designated for preventing data races to a particular variable. Atomic operations don't require any additional places in memory to work.