Specifications

D
evice Driver Programming
11-8
Upon acquiring a lock with the priority level set at the specified pl, LOCK returns the pre-
vious priority level to the caller.
NOTE
Be sure that the calling context has not already acquired the speci-
fied spin lock using LOCK because a deadlock results.
To attempt to acquire the lock without busy waiting if the lock is not immediately avail-
able, you use the TRYLOCK routine:
#include <sys/types.h>
#include <sys/ksynch.h>
#include <sys/ddi.h>
pl_t TRYLOCK(lockp
,
pl)
lock_t *lockp
;
pl_t pl;
where:
lockp is a pointer to the basic lock to be acquired.
pl is the interrupt priority level argument to be set while the lock is held by the caller.
Upon acquiring the lock, TRYLOCK returns the previous priority level. If the lock is not
acquired, it returns the value invpl (invalid IPL).
To release a lock, you use the UNLOCK routine:
#include <sys/types.h>
#include <sys/ksynch.h>
#include <sys/ddi.h>
void UNLOCK(lockp
,
pl)
lock_t *lockp
;
pl_t pl;
where:
lockp is a pointer to the basic lock to be released.
pl is the interrupt priority level to be set after releasing the lock.
The UNLOCK routine has no return value.
Finally, to deallocate a basic lock, you use the LOCK_DEALLOC routine: