STREAMS/UX for the HP 9000 Reference Manual

82
STREAMS/UX Multiprocessor Support
Writing MP Scalable Modules and Drivers
the same group. They can all share data. However, STREAMS/UX will not
synchronize bufcall and timeout callback functions or any non-STREAMS/UX
code with the modules or drivers. You may be able to use the streams_put utility
described in Chapter 3. In general, UP emulation provides more protection for
bufcall, timeout, and non-STREAMS functions.
To change modules and drivers to be MP scalable, analyze how the code shares
data structures. Determine which structures are shared and which module and
driver entry points read and write to the structures. Using this information, choose
synchronization levels for modules and drivers that correctly serialize access to
shared data.
If all modules and drivers of a product share the same structure, consider
changing the module and driver data structures and algorithms to allow for more
parallelism. Alternatively, consider using spinlocks to protect shared structures
that are accessed infrequently or for short amounts of time. Using spinlocks is a
good way to protect structures which are not accessed on the main read and write
paths. You can either use the native HP-UX spinlock primitives or the SVR4 MP
LOCK, TRYLOCK, UNLOCK, LOCK_ALLOC and LOCK_DEALLOC utilities.
The SVR4 MP utilities are discussed under “HP-UX Modifications to
STREAMS/UX Utilities” in Chapter 3 and in the SVR4.2 Driver manual.
Use service routines only for flow control, recovering from resource shortages or
executing interrupt completions in a process context. Service routines degrade
performance.
Be careful when writing timeout and bufcall callback functions, as well as
non-STREAMS code that calls STREAMS/UX utilities or shares data with
modules and drivers. See the “Guidelines for MP Scalable Modules and Drivers”
section.
Configuring MP Scalable Modules and Drivers
This section describes how to configure MP scalable modules and drivers.
MP Scalable Module and Driver Configuration
If you want a module or driver to be MP scalable, you must specify
additional configuration parameters. You need to:
Add a flag indicating that the module or driver is MP scalable
Add a keyword which specifies the synchronization level the module or driver
uses
Add a sync name if the module or driver requires elsewhere synchronization