|
|
int intralloc(struct lockb lock_xxtab, int (xxstart)());int intrallocs(struct lockb lock_xxtab, int (xxstart)(), char dev_name);
startio(D3oddi) takes the handle returned by intralloc or intrallocs to run xxstart on a processor that can access the I/O bus.
Use either intralloc or intrallocs with startio when not all processors can access the I/O bus from within the driver's strategy(D2oddi) entry point routine (determined by calling all_io(D3oddi)).
Otherwise, the handle value is returned.
``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(D3oddi) to determine if all the processors can access the I/O bus. If so, bdistributed 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( ) to register the driver's start(D2oddi) routine for later use by startio(D3oddi).
If the call to <intralloc( ) fails, a message should be generated to warn users that your driver is denied multiprocessor access; this is illutrated in lines 12 and 13. If <intralloc( ) succeeds, bdistributed(D3oddi) is called in line 15.