Spinlock

Exclusive spin-based lock wrapper with explicit initialization, locking, and unlocking operations. The wrapper has no shared-lock mode or try operation.


Spinlock model


Spinlock

Methods

INIT (--) Resets the lock state to UNLOCKED.
lock (--) Acquires the lock in exclusive mode by repeatedly attempting the transition from UNLOCKED to LOCKED until one attempt succeeds.
unlock (--) Releases one exclusive lock acquisition.

Preconditions

  • The current state is LOCKED.

Remarks


See also