As per my understanding, any atomic instructions(compare_and_swap, test_and_test, fetch_and_add) are executed as a single instruction. Though they involve multiple CPU cycles/operations, it is invisible to the thread/process. If a thread is executing any such atomic instruction, no other thread is allowed to modify/access any values(memory locations/registers) involved in such atomic instruction.
If that is the case, Why in wikipedia http://en.wikipedia.org/wiki/Compare-and-swap, it is stated that if the value had been updated by another thread in the meantime, the write would fail. ?
How can other thread update the value while compare_and_swap instruction in one thread is under progress ?