int canlock(Lock *l)
void unlock(Lock *l)
void ilock(Lock *l)
void iunlock(Lock *l)
Lock loops repeatedly attempting acquire the spin lock l until it succeeds. Lock should not be used to lock a structure shared with an interrupt handler unless interrupts are disabled by splhi(10.2) before attempting the lock; it is better to use ilock, below.
Canlock is non-blocking. Only one attempt is made for the lock. It returns non-zero if the lock was successfully acquired; 0 otherwise.
Unlock releases the lock l. A lock must be unlocked only by the locking process.
When called by a process, the functions above temporarily boost its priority to the highest priority, PriLock; its original priority is restored at the end of the critical section by unlock. On a uniprocessor, if l is unavailable, lock can reschedule unless interrupts are disabled before entering lock or there is no current process (eg, when executing the scheduler).
Ilock disables interrupts before attempting to acquire the lock. It should be used to lock a resource shared between a process and an interrupt handler. On a uniprocessor, disabling interrupts is sufficient to exclude an interrupt handler from the critical section, and on a multiprocessor the spin lock excludes an interrupt handler running on another processor. Ilock never reschedules the caller, nor must a caller allow itself to be rescheduled (eg, by calling sleep(10.2)) before releasing the lock.
Iunlock releases a lock previously got by ilock.
lock loop on lock-address key key-value pc caller-pc held by pc lock-pc
Most lock loops represent deadlocks caused by failing to unlock a resource, attempting to lock (eg, by recursive call) a resource already held by the process, inconsistent locking and unlocking of nested resources, using a spin-lock to guard code that reschedules, using lock not ilock to interlock with an interrupt routine, and similar blunders.
LOCK(10.2 ) | Rev: Thu Feb 15 14:42:59 GMT 2007 |