Specifications
Multithreading a Device Drive
r
11-
7
Note that strictly speaking, the interrupt levels listed here are machine independent
abstractions of the hardware interrupt priority levels used by a hardware platform. In
particular, the interrupt levels defined here have no absolute value, but a relative
ordering. Setting a given priority level blocks interrupts at or below that level. The
following partial order is defined:
pltimeout < pldisk, plstr <= plhi.
The ordering of pldisk and plstr relative to each other is undefined. You should
choose an interrupt level that is high enough to block out any interrupt handler that
might attempt to acquire this lock.
NOTE
Do not use the plbase priority value for the min_pl argu-
ment.The plbase priority value is invalid because it does not
block any interrupts.
lkinfo_p is a pointer to a lkinfo structure. The lk_name component of the
lkinfo structure points to a character string defining a name that identifies the
lock. This name should begin with the driver prefix. The lkinfo structure can be
shared only with other basic locks or read/write locks. It cannot be shared with sleep
locks.
flag specifies if the caller can sleep waiting for memory if sufficient memory is not
immediately available to allocate the synchronization variable. If flag is set to
KM_SLEEP, the caller sleeps if necessary until sufficient memory is available. If flag
is set to KM_NOSLEEP and if sufficient memory is not immediately available, the
routine does not sleep but returns immediately with an error.
Upon successful completion, LOCK_ALLOC returns a pointer to the lock just allocated. If
KM_NOSLEEP is specified and sufficient memory is not immediately available,
LOCK_ALLOC returns a NULL pointer.
Once the lock has been allocated, the driver can attempt to acquire the lock using the
LOCK routine:
#include <sys/types.h>
#include <sys/ksynch.h>
#include <sys/ddi.h>
pl_t LOCK(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.
LOCK attempts to acquire the lock specified by lockp. If the lock is not immediately avail-
able, the caller busy waits until the lock is available.