- #1
Peon666
- 108
- 0
I understand that the purpose of the TestAndSet() instruction is to test and contents of the register and set new values. (returning the old value). I have a question regarding this instruction:
-Wikipedia.
In this code, initial is the old value, and lock is the new one. The instruction:
replaces the old value with the new one. And the instruction:
returns the modified value. But what does this instruction do?:
I'd be really thankful if someone explains this a bit.
Code:
function TestAndSet(boolean lock) {
boolean initial = lock
lock = true
return initial
}
In this code, initial is the old value, and lock is the new one. The instruction:
Code:
boolean initial = lock
replaces the old value with the new one. And the instruction:
Code:
return initial
returns the modified value. But what does this instruction do?:
Code:
lock = true
I'd be really thankful if someone explains this a bit.