LOCK LOCK THE BUS LOCK
Operation:
None
Description:
LOCK is a
The instruction most useful in this context is an exchange register with memory. A simple software lock may be implemented with the following code sequence:
Encoding:
11110000
Flags Affected:
None
Check: | MOV | AL,1 | ;set AL to 1 (implies locked) |
LOCK | XCHG | Sema,AL | ;test and set lock |
| TEST | AL,AL | ;set flags based on AL |
| JNZ | Check | ;retry if lock already set |
| MOV | Sema,O | ;clear the lock when done |
The LOCK prefix may be combined with the segment override and/or REP prefixes.
LOCK Operands Clocks Transfers Bytes LOCK Coding Example
(no operands) | 2 | - | 1 | LOCK XCHG FLAG,AL |