A computer processor includes a number of register pairs LOCKADD/LOCKCOUNT
to hold values identifying when a computer resource is locked. The
LOCKCOUNT register is incremented or decremented in response to lock or
unlock instructions, respectively. The lock is freed when a count
associated with the LOCKCOUNT register is decremented to zero. In
embodiments without LOCKOUT registers, the lock may be freed on any unlock
instruction corresponding to the lock. In some embodiments, a computer
object includes a header in which two header LSBs store: (1) a LOCK bit
indicating whether the object is locked, and (2) a WANT bit indicating
whether a thread is waiting to acquire a lock for the object.