Advanced Computer Architecture Chapter 7.
53
Uninterruptable Instruction to Fetch and
Update Memory
Atomic exchange
: interchange a value in a register for a value in
memory
–
0 => synchronization variable is free
–
1 => synchronization variable is locked and unavailable
Set register to 1 & swap
New value in register determines success in getting lock
0 if you succeeded in setting the lock (you were first)
1 if other processor had already claimed access
Key is that exchange operation is indivisible
Test-and-set
: tests a value and sets it if the value passes the test
Fetch-and-increment
: it returns the value of a memory location and
atomically increments it
0 => synchronization variable is free