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
262
unweldq
weldq
The strenv.h file redefines some native HP-UX kernel utilities to conform to System V Release 4.2. The
strenv.h file redefines delay, get_sleep_lock, kmem_alloc, kmem_free, lbolt, max, min, sleep, time,
timeout, and untimeout. These defines might collide with declarations in STREAMS/UX modules and
drivers. The strenv.h file can be customized to avoid collisions or to use native HP-UX utilities. However,
modules and drivers cannot call the native HP-UX sleep or get_sleep_lock directly. If modules and drivers
call sleep or get_sleep_lock, they must include strenv.h to redefine sleep and get_sleep_lock to
streams_mpsleep and streams_get_sleep_lock.
Differences between the STREAMS/UX kernel utilities and the descriptions in the SVR4.2 Driver manual are
discussed here, along with information about new utilities. This section assumes that modules and drivers
include strenv.h.
cmn_err
The STREAMS/UX cmn_err is the same as the cmn_err described in the SVR4.2 Driver manual with a few
differences. The HP-UX cmn_err always sends messages to both the system console and the circular kernel
buffer. Inserting an exclamation point (“!”) or a circumflex (“^”) as the first character in the format string has
no effect. HP-UX simply removes these control characters from the message, and sends the message to both
the console and the kernel buffer. There are a couple of other very minor differences. HP-UX precedes
CE_PANIC level messages with the string panic: instead of PANIC:. Also, the HP-UX circular kernel buffer is
called msgbuf instead of putbuf. The HP-UX msgbuf is a fixed size, and can be viewed using the dmesg
command or the KWDB debugger tool.
esballoc
The STREAMS/UX esballoc is the same as the esballoc call described in the SVR4.2 Driver manual with a
few differences. The HP-UX esballoc copies the contents of the fr_rtn structure into an area of the message
block not visible to the STREAMS/UX programmer. The free routine passed to esballoc can call
STREAMS/UX utilities in the same way as the put or service procedure that called freeb. Also, a free routine
can safely access the same data structures as the put or service routine that called freeb. However, unlike
SVR4.2, HP-UX does not block interrupts from all STREAMS/UX devices while the free routine runs.
freezestr and unfreezestr
The SVR4.2 Driver manual says that freezestr and unfreezestr must be called on multiprocessors to
protect searching a STREAMS/UX queue and calling insq, rmvq, strqset, and strqget. SVR4 MP provides
freezestr and unfreezestr to prevent software on multiple processors from manipulating a queue’s list of
messages at the same time. STREAMS/UX uses synchronization levels for this. Appendix-F for more
information about synchronization levels. STREAMS/UX uses a different mechanism to protect
STREAMS/UX queues. Thus the HP-UX freezestr/unfreezestr mechanisms are different from SVR4.2
definitions in that they freeze/unfreeze the state of a single queue and not the state of the entire stream
containing the queue.
All modules/drivers with the synchronization level SQLVL_NOSYNC still need to call freezestr to freeze the
queue. The call to freezestr needs to be done before calling insq, rmvq, strqget, and strqset to prevent
multiple put routines running on different processors from manipulating the same queue. A call to
unfreezestr must be made to unfreeze the queue.
For module/drivers with a synchronization level other than SQLVL_NOSYNC, freezestr returns the current
interrupt priority level, and unfreezestr is a no-op. HP-UX provides the freezestr and unfreezestr stubs
for easier porting of code from SVR4 MP, for these levels.