If you specify WC with your LOCKSET, the C flag will show the "previous lock state". You can then do a IF_C JMP to loop until the lock was previously false. If the previous lock value was true, someone else already had the lock. In either case, the lock value will be true after the LOCKSET command.
I found this description of the lockset instruction. It helped me understand the logic behind using locks. Can't remember who posted it.
"The LOCKSET instruction reads the current state of the lock bit and ALWAYS sets the lock to one. The previous state of the lock is written to the C flag. If the C flag is 0 (IF_NC) then nobody had the lock set before you, so now it's yours (and set to 1). If the C flag is 1 (IF_C) then another process already had the lock set and you should wait."
Comments
Jonathan
[edit: pun not intended, a spinlock is a standard thing in multiprocessor hardware - compare semaphore, event counter]
"The LOCKSET instruction reads the current state of the lock bit and ALWAYS sets the lock to one. The previous state of the lock is written to the C flag. If the C flag is 0 (IF_NC) then nobody had the lock set before you, so now it's yours (and set to 1). If the C flag is 1 (IF_C) then another process already had the lock set and you should wait."