.TH TRYLOCK() "" "" "DDI/DKI Kernel Routine"
.PC "Acquire a basic lock"
.B "#include <sys/ksynch.h>"
.B "#include <sys/types.h>"
\fBpl_t TRYLOCK(\fIlock\^\fB, \fIpriority\^\fB)\fR
\fBlock_t *\fIlock\^\fB; pl_t \fIpriority\^\fB;\fR
.PP
.B TRYLOCK()
acquires
.IR lock ,
with interrupt
.IR priority .
If
.I lock
is available,
.B TRYLOCK()
returns its previous level of interrupt priority.
However, if it is not,
.B TRYLOCK()
immediately returns
.B invpl
without waiting to acquire the lock.
.PP
For a driver to be portable,
it should set
.I priority
to a value high enough to block any interrupt handler
that attempts to acquire
.IR lock .
When a function calls
.B TRYLOCK()
from interrupt level, it must not set
.I priority
to less than the level at which the interrupt handler runs.
For a list of the valid values for
.IR priority ,
see the entry for
.BR LOCK_ALLOC() .
.SH "See Also"
.B
DDI/DKI kernel routines,
LOCK(),
LOCK_ALLOC(),
LOCK_DEALLOC(),
UNLOCK()
.R
.SH Notes
.B TRYLOCK()
has base or interrupt level.
It does not sleep.
.PP
A driver can hold a
driver-defined basic lock, read/write lock, or sleep lock
across a call to this function.
