|
|
#include <sys/ci/cidriver.h>int all_io(int bustype);
1 is returned if all processors can perform I/O to or from a device on the specified bus.
1 is also returned if only one processor is present in the system.
``Multithreaded drivers'' in HDK Technical Reference
1 #include <sys/arch.h>
2 #include <sys/conf.h>
3 int xxhandle = -1;
4 xxinit()
5 {
6 ...
7 if (all_io(archtobus(arch)))
8 bdistributed(xxstrategy, DIST_BDEV_STRATEGY);
9 else if (xxhandle == -1) {
10 handle = intralloc(&lock_xxtab, xxstart);
11 if (handle == -1)
12 cmn_err(CE_WARN,
13 "xxinit: Multiprocessor access denied");
14 else
15 bdistributed(xxstrategy, DIST_BDEV_STRATEGY);
16 }
17 ...
18 }
Line 7 calls
all_io( )
to determine if all the processors
can access the I/O bus.
If so,
bdistributed(D3oddi)
is called in line 8 to indicate
that the driver can be accessed by more than one processor.
If some processors cannot access the I/O bus, the driver must use the startio(D3oddi) routine to ensure that its start(D2oddi) routine is always run on a processor capable of performing I/O. Line 10 calls intralloc(D3oddi) to register the driver's start( ) routine for later use by startio( ).
If the call to intralloc( ) fails, a message should be generated to warn users that your driver is denied multiprocessor access; this is illustrated in lines 12 and 13. If intralloc( ) succeeds, bdistributed( ) is called in line 15.