Could someone explain to me the working and differences of above operations in multi-threading?
+3
A:
test-and-set
modifies the contents of a memory location and returns its old value as a single atomic operation.
compare-and-swap
atomically compares the contents of a memory location to a given value and, only if they are the same, modifies the contents of that memory location to a given new value.
The difference marked in bold.
Kirill V. Lyadvinsky
2010-09-07 14:23:55