STREAMS-UX Programmer's Guide (February 2007)

Differences Between STREAMS/UX and System V Release 4 STREAMS
HP-UX Modifications to STREAMS/UX Utilities
Appendix E
263
get_sleep_lock
STREAMS/UX provides some extra support for modules and drivers which use the native HP-UX
get_sleep_lock primitive. Alternatively, modules and drivers can call the SVR4 MP SV_WAIT and
SV_WAIT_SIG. Open and close routines call get_sleep_lock before sleeping to prevent missing wakeups.
After calling get_sleep_lock, the open or close can release spinlocks before sleeping. Other processes cannot
wakeup the open or close between the time it calls get_sleep_lock and sleep. Modules and drivers must
include strenv.h to use get_sleep_lock. strenv.h redefines get_sleep_lock to
streams_get_sleep_lock. Modules and drivers cannot call the native HP-UX get_sleep_lock directly,
because STREAMS/UX needs to do some additional synchronization before invoking get_sleep_lock.
lock_t * get_sleep_lock(caddr_t event);
The open or close routine passes the event it will pass to the sleep primitive to get_sleep_lock.
get_sleep_lock obtains a sleep spinlock, and returns a pointer to this lock.
itimeout
If the HP-UX itimeout cannot allocate memory, it panics instead of returning 0 like the SVR4 MP itimeout.
The STREAMS/UX itimeout only returns 0 if it is passed an interrupt priority level that is lower than
pltimeout.
kmem_alloc
A value of 0 for the size parameter is illegal in STREAMS/UX kmem_alloc(). The SVR4.2 kmem_alloc
returns NULL instead.
LOCK
The STREAMS/UX LOCK calls the native HP-UX spinlock primitive. LOCK has an interrupt priority level
parameter, which is used to raise the priority level and block interrupts which acquire the spinlock. The
SVR4.2 Driver manual says that implementations which do not need to raise the interrupt level can ignore
this parameter. Since the HP-UX spinlock primitive always raises the interrupt level to spl6 while a spinlock
is held, STREAMS/UX ignores the interrupt level parameter on multiprocessor systems. For better
performance on uniprocessor systems, the STREAMS/UX LOCK raises the priority level to the parameter
value instead of acquiring a spinlock. Whether the caller will block or spin if the lock cannot be obtained is
implementation defined. The HP-UX implementation spins.
LOCK_ALLOC
The STREAMS/UX LOCK_ALLOC calls the native HP-UX alloc_spinlock primitive. There are some small
differences between the STREAMS/UX LOCK_ALLOC and the SVR4 MP utility. The LOCK_ALLOC has a flag
parameter which indicates if the caller is willing to block while waiting for memory to be allocated. HP-UX
only allows this flag to be set to KM_SLEEP, and returns zero if it is set to KM_NOSLEEP. The STREAMS/UX
LOCK_ALLOC accepts the following hierarchy parameter values which are reserved for STREAMS/UX modules
and drivers in /usr/include/sys/semglobal.h:
STREAMS_USR1_LOCK_ORDER
STREAMS_USR2_LOCK_ORDER
STREAMS_USR3_LOCK_ORDER