Multithreaded STREAMS
A new SCO OpenServer 5 Release 5 feature is support for
multithreaded STREAMS drivers.
This allows STREAMS drivers to run
on all CPUs in a multiprocessing platform,
which can significantly improve system performance.
The specifics of the multithreaded STREAMS interface
are summarized below:
-
The following can execute on any processor
in a multithreaded driver that is registered
as a distributed driver:
-
STREAMS head code.
-
servicing of STREAMS service routines.
Note, however, that only a single instance of the service routine
for any given STREAMS queue
is active at any given time,
just as it is in a single-threaded driver.
-
put routines of multithreaded drivers and modules.
-
Initialization, open, and close routines
will run only on the default CPU
even when the driver is registered as distributed.
Most STREAMS drivers do their interesting work
at put, service, and interrupt time,
so this does not have much impact on system performance.
-
The put and service routines of STREAMS drivers
that do not declare themselves as multithreaded
execute on the default CPU.
-
The
putnext(D3str)
macro is now a function that checks the next queue.
If the queue is not registered as multithreaded,
the message is placed on a global queue called
the putnext queue which is serviced
only by the default CPU.
-
The STREAMS queue_t queue data structure
and the STREAMS struct stdata structure
have been extended with a parallel set of data structures
that store locks and other information
that is required to support multithreaded modules and drivers.
These structures are called equeue_t
and struct estdata.
To register the task-time level of a STREAMS driver
as multithreaded, issue the
sdistributed(D3oddi)
function from the driver's
xxopen( )
routine after all other initialization is complete.
Arguments to
sdistributed( )
indicate which put and service routines
are multithreaded.
Use the
MPSTR_QLOCK(D3str)
and
MPSTR_QRELE(D3str)
functions to protect critical code
that accesses the STREAMS queue_t data structure.
Use the
MPSTR_STPLOCK(D3str)
and
MPSTR_STPRELE(D3str)
functions to protect critical code
that accesses the Stream head.
To multithread the interrupt level of a STREAMS driver,
issue the
idistributed(D3oddi)
function from the driver's
open(D2str)
routine.
Multithreaded drivers must use locks rather than the
spl(D3oddi)
functions to protect critical code sections.
For more information about the SCO multiprocessing architecture
and protecting critical code sections
in multithreaded drivers, see
``Multithreading device drivers''.
© 2005 The SCO Group, Inc. All rights reserved.