Specifications
D
evice Driver Programming
11-10
#include <sys/types.h>
#include <sys/kmem.h>
#include <sys/ksynch.h>
#include <sys/ddi.h>
rwlock_t *RW_ALLOC(hierarchy, min_pl, lkinfo_p, flag)
uchar_t hierarchy;
pl_t min_pl;
lkinfo_t *lkinfo_p;
int flag
;
where:
hierarchy is the hierarchy value that asserts the order in which to acquire the lock rel-
ative to other basic and read/write locks. Acceptable hierarchy values range from 1
to 32 inclusive.
When acquiring a lock using any function other than TRYLOCK(D3), the lock
must have a hierarchy value that is strictly greater than the hierarchy values cur-
rently held by the calling context. For example, if lock B is to be acquired uncondi-
tionally while holding lock A, then the hierarchy value associated with lock B
should be strictly greater than the hierarchy value associated with lock A. The hier-
archy values of multiple locks held at any point in time must form a strict ordering.
Further, if one or more locks are acquired at distinct priority levels, you should
define subranges of hierarchy values for each priority level and pick a value from
these subranges. For example, if M is the hierarchy value defined for any lock that
can be acquired at priority level N, then M+1 should be the minimum hierarchy
value defined for any lock that can be acquired at any priority level greater than N.
min_pl is the minimum priority level argument that asserts the minimum priority
level passed in with any attempt to acquire the lock.
The valid priority level arguments for the basic lock allocation and locking inter-
faces are listed below:
pltimeout Block functions scheduled by
itimeout(D3) and dtimeout(D3)
pldisk Block disk device interrupts
plstr Block STREAMS interrupts
plhi Block all interrupts
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.