HPlogo STREAMS/UX for the HP 9000 Reference Manual > Chapter 4 STREAMS/UX Multiprocessor Support

MP Synchronization Levels on a Uniprocessor

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

This section describes how modules and drivers can use MP synchronization levels on a uniprocessor system to protect their private data structures against interrupts. Please read "Writing MP Scalable Modules and Drivers" in this chapter and "STREAMS/UX Uniprocessor Synchronization" in Chapter 3 before reading this section.

In addition to the techniques described under "Driver and Module Synchronization" in Chapter 3, modules and drivers can use MP synchronization levels to protect their private structures against interrupts. By default STREAMS/UX configures modules and drivers to use queue pair synchronization. This is why modules and drivers do not need to raise the spl level to protect their data if software running on the ICS sends a message to a stream. Suppose an interrupt occurs while one of a queue pair's entry points is running. STREAMS/UX will re-schedule sending the message to the stream to after the entry point finishes executing. You can configure uniprocessor modules and drivers to use synchronization levels other than queue pair synchronization if they need more protection.

For example, you could configure a module to use module synchronization if multiple instances of the module share the same data structure, and if the module updates the structure when it is running on the ICS. If you configure the module to use module synchronization, STREAMS/UX will wait until no instances of the module are running before sending it a message. Alternatively, you could change the module to raise the spl level while accessing the shared structure.

You configure synchronization levels for modules and drivers that run on a uniprocessor system in the same way as for MP scalable modules and drivers. You must specify the synchronization level the module or driver uses, and if the module or driver requires elsewhere synchronization, you must specify a sync name. The sync name indicates which modules and drivers belong to a group. Pick a sync name with 8 or fewer characters, and configure the name for each member of the group. You configure the synchronization level and the sync name in either the master file $STREAMS_DVR_SYNC table or in an install function streams_info_t structure.

You can configure modules and drivers to use a particular synchronization level whether or not they are MP scalable, run under UP emulation, or only run on a uniprocessor system. The section "Configuring MP Scalable Modules and Drivers" in this chapter shows examples of configuring MP scalable modules and drivers to use synchronization levels. There is no difference between configuring modules and drivers which run only on a uniprocessor system and modules and drivers which run under UP emulation. Examples of configuring uniprocesor/UP emulation modules and drivers are shown below. Examples are given for both master file entries and module and driver install functions. See Chapter 5 for more information about configuring modules and drivers.

MASTER FILE $DEVICE TABLE CONFIGURATION

* name handle type mask block char
*
$DEVICE
A Ainfo 40 2000 -1 -1 /* UP module, since 0x10000 not in mask */
B Binfo 40 2000 -1 -1 /* UP module, since 0x10000 not in mask */
C Cinfo 40 2000 -1 -1 /* UP module, since 0x10000 not in mask */
D Dinfo 21 20FC -1 116 /* UP driver, since 0x10000 not in mask */

$$$
* name sync level sync name
*
$STREAMS_DVR_SYNC
A sync_module /* Module uses synch level */
B sync_module /* Module uses synch level */
C sync_elsewhere netsync /* Module uses synch level & name */
D sync_elsewhere netsync /* Driver uses synch level & name */
$$$
INSTALL FUNCTION CONFIGURATION

B MODULE

static streams_info_t b_str_info = { /* streams information */
"B", /* name */
-1, /* major number */
{ &brinit, &bwinit, NULL, NULL }, /* streamtab */
STR_IS_MODULE | STR_SYSV4_OPEN, /*NOTE* MGR_IS_MP not specified */
    SQLVL_MODULE,                     /*NOTE* synch level specified */
"", /* sync name */
}

int
B_install()
{
int retval;

return(str_install(&b_str_info));

}

D DRIVER

static drv_info_t d_drv_info = { /* driver information */
"D", /* name */
"pseudo", /* class */
DRV_CHAR | DRV_PSEUDO, /*NOTE* DRV_MP_SAFE flag not specified */

     -1,                           /* block major number */
-1 /* dynamically assigned character major number */
    NULL, NULL, NULL,       /* cdio, gio_private,and cdio_private structures 
*/
structures */
}
static drv_ops_t d_drv_ops = {      /* driver entry points */
NULL, /* open */
NULL, /* close */
NULL, /* strategy */
NULL, /* dump */
NULL, /* psize */
NULL, /* mount */
NULL, /* read */
NULL, /* write */
NULL, /* ioctl */
NULL, /* select */
NULL, /* option1 */
NULL, NULL, NULL, NULL, /* reserved entry points */
0, /* device flags */
}
static streams_info_t d_str_info =  {  /* streams information */
"D", /* name */
-1, /* dynamically assigned major number */
{ &drinit, &dwinit, NULL, NULL}, /* streamtab */
STR_IS_DEVICE | STR_SYSV4_OPEN, /*NOTE* MGR_IS_MP flag not specified */
SQLVL_ELSEWHERE, /*NOTE* synch level specified*/
"netsync", /*NOTE* sync name specified */
}

int
D_install()
{
int retval;

/* Configure driver and obtain dynamically assigned major number. */
if ((retval = install_driver(&d_drv_info, &d_drv_ops)) != 0)
return(retval);

/* Configure streams specific parameters. */
if ((retval = str_install(&d_str_info)) != 0) {
uninstall_driver(&d_drv_info);
return(retval);
}

/* Success */
return 0;

}

static streams_info_t d_str_info =  {  /* streams information */
"D", /* name */
-1, /* dynamically assigned major number */
{ &drinit, &dwinit, NULL, NULL}, /* streamtab */
STR_IS_DEVICE | STR_SYSV4_OPEN, /*NOTE* MGR_IS_MP flag not specified */
SQLVL_ELSEWHERE, /*NOTE* synch level specified*/
"netsync", /*NOTE* sync name specified */
}

int
D_install()
{
int retval;

/* Configure driver and obtain dynamically assigned major number. */
if ((retval = install_driver(&d_drv_info, &d_drv_ops)) != 0)
return(retval);

/* Configure streams specific parameters. */
if ((retval = str_install(&d_str_info)) != 0) {
uninstall_driver(&d_drv_info);
return(retval);
}

/* Success */
return 0;

}

The following table indicates if spinlocks can be held across calls to different STREAMS/UX utilities. Also, it specifies if the SVR4 MP STREAMS/UX utilities have the same restrictions.

Table 4-1 Holding Module or Driver Defined Spinlocks While Calling Utilities

Utility

Spinlocks Can Be Held Across Call?

Differs From SVR4 MP?

adjmsg

Yes

No

allocb

Yes, if use STREAMS/UX user lock orders.

No

backq

Yes

No

bcanput

Yes, if use STREAMS/UX user lock orders.

No

bcanputnext

Yes, if use STREAMS/UX user lock orders.

No

bcopy

Yes

No

bufcall

Yes, if use STREAMS/UX user lock orders.

bzero

Yes

No

canput

Yes, if use STREAMS/UX user lock orders.

No

canputnext

Yes, if use STREAMS/UX user lock orders.

No

cmn_err

No

Yes

copyb

Yes, if use STREAMS/UX user lock orders.

No

copymsg

Yes, if use STREAMS/UX user lock orders.

No

datamsg

Yes

No

delay

No

No

drv_getparm

Yes

No

drv_priv

Yes

No

dupb

Yes, if use STREAMS/UX user lock orders.

No

dupmsg

Yes, if use STREAMS/UX user lock orders.

No

enableok

Yes, if use STREAMS/UX user lock orders.

No

esballoc

Yes, if use STREAMS/UX user lock orders.

No

esbbcall

Yes, if use STREAMS/UX user lock orders.

No

flushband

Yes, if use STREAMS/UX user lock orders (flushband may call user esballoc free routines).

No

flushq

Yes, if use STREAMS/UX user lock orders (flushq may call user esballoc free routines).

No

freeb

Yes, if use STREAMS/UX user lock orders (freeb may call user esballoc free routines).

No

freemsg

Yes, if use STREAMS/UX user lock orders (freemsg may call user esballoc free routines).

No

freezestr

Yes

No

getadmin

Yes, if use STREAMS/UX user lock orders.

No

getmid

Yes, if use STREAMS/UX user lock orders.

No

getmajor

Yes

No

getminor

Yes

No

getq

Yes, if use STREAMS/UX user lock orders.

No

insq

Yes, if use STREAMS/UX user lock orders.

No

itimeout

Yes, if use STREAMS/UX user lock orders.

No

kmem_alloc

Yes, if use STREAMS/UX user lock orders and KM_NOSLEEP.

No

kmem_free

Yes, if use STREAMS/UX user lock orders.

No

linkb

Yes

No

LOCK

Yes, if use lock orders correctly.

No

LOCK_ALLOC

No

Yes

LOCK_DEALLOC

Yes, if use STREAMS/UX user lock orders.

No

major

Yes

No

makedev

Yes

No

makedevice

Yes

No

max

Yes

No

min

Yes

No

minor

Yes

No

msgdsize

Yes

No

msgpullup

Yes, if use STREAMS/UX user lock orders.

No

noenable

Yes, if use STREAMS/UX user lock orders.

No

OTHERQ

Yes

No

pcmsg

Yes

No

pullupmsg

Yes, if use STREAMS/UX user lock orders.

No

put

No

No

putbq

Yes, if use STREAMS/UX user lock orders.

No

putctl

No

No

putctl1

No

No

putctl2

No

No

putnext

No

No

putnextctl

No

No

putnextctl1

No

No

putnextctl2

No

No

putq

Yes, if use STREAMS/UX user lock orders, and does not pass driver's read queue or lower mux's write queue.

Yes

qenable

Yes, if use STREAMS/UX user lock orders.

No

qprocsoff

Yes

Yes

qprocson

Yes

Yes

qreply

No

No

qsize

Yes

No

RD

Yes, if use STREAMS/UX user lock orders.

No

rmvb

Yes

No

rmvq

Yes, if use STREAMS/UX user lock orders.

No

SAMESTR

Yes, if use STREAMS/UX user lock orders.

No

sleep

No

No

spln

No

Yes

splstr

No

Yes

streams_put

No

No

streams_get_sleep_lock

Yes, if use STREAMS/UX user lock orders.

No

strlog

No

Yes

strqget

Yes, if use STREAMS/UX user lock orders.

No

strqset

Yes, if use STREAMS/UX user lock orders.

No

SV_ALLOC

Yes, if use STREAMS/UX user lock orders and KM_NOSLEEP.

No

SV_BROADCAST

Yes, if use STREAMS/UX user lock orders.

No

SV_DEALLOC

Yes, if use STREAMS/UX user lock orders.

No

SV_WAIT

No, except for lkp parameter lock.

No

SV_WAIT_SIG

No, except for lkp parameter lock.

No

testb

Yes, if use STREAMS/UX user lock orders.

No

timeout

Yes, if use STREAMS/UX user lock orders.

No

TRYLOCK

Yes

No

unbufcall

No

No

unfreezestr

Yes

No

unlinkb

Yes

No

UNLOCK

Yes

No

untimeout

Yes, if locks can be held across call to timeout callback function.

No

unweldq

Yes, if use STREAMS/UX user lock orders.

No

vtop

Yes

No

wakeup

Yes, if use STREAMS/UX user lock orders.

No

weldq

Yes, if use STREAMS/UX user lock orders.

No

WR

Yes, if use STREAMS/UX user lock orders.

No

 

© 1995 Hewlett-Packard Development Company, L.P.