|
Support in ISA
- Recall: All instructions in a processor execute uninterrupted.
- Within a single processor, instructions are atomic.
- Pentium ISA provide xchg instruction. (Swap instruction)
xchg(register r, memory_address a) {
t = r; r = *a; *a = t;
}
- One Read and One write in memory and register each.
Implementing Locks Using Swap
- Acquire Lock:
Register AX = TRUE;
While (AX=TRUE) xchg(AX, &lock);
- Release Lock:
|