|
|
#include <sys/ddi.h>pl_t splbase(void); pl_t spltimeout(void); pl_t spldisk(void); pl_t splstr(void); pl_t spltty(void); pl_t splhi(void); pl_t spl0(void); pl_t spl7(void);
void splx(pl_t level);
On a multiprocessor system, interrupts may be serviced by more than one processor and, therefore, use of an spl function alone is not sufficient to prevent interrupt code from executing and manipulating driver data structures during a critical section. Drivers that must prevent execution of interrupt-level code in order to protect the integrity of their data should use basic locks or read/write locks for this purpose; see ``Spin locks (DDI)'' in HDK Technical Reference.
The spl functions include the following:
To ensure driver portability, the named spl functions (such as splbase or spltimeout) should be used whenever possible. The numbered spl functions (spl0 and spl7) should be used only when an interrupt priority level must be set to a specific value.
Calling a given spl function will block interrupts specified for that function as well as interrupts at equal and lower levels. The notion of low vs. high levels assumes a defined order of priority levels. The following partial order is defined:
splbase <= spltimeout <= spldisk,splstr <= splhi
The ordering of spldisk and splstr relative to each other is not defined.
When setting a given priority level, the previous level returned should be saved and splx, UNLOCK(D3), or RW_UNLOCK(D3) should be used as appropriate to restore this level.
Interrupt-level code must never lower the interrupt priority level below the level at which the interrupt handler was entered. For example, if an interrupt handler is entered at the priority level associated with spldisk, the handler must not call spltimeout.
A multithreaded driver may not use spl functions. A single-threaded driver may use both locks and spls, although the only reasonable use for locks in a non-multithreaded driver is to access data structures that are shared with other cooperating drivers or cooperating daemons. Using a lock in place of an spl call for a data structure that is managed totally within a non-multithreaded driver is overkill.
Driver-defined basic locks and read/write locks may be held across calls to these functions, but the spl call must not cause the priority level to be lowered below the level associated with the lock.
In DDI versions prior to version 8, spl0 is an alias for splbase and spl7 is an alias for splhi.
``Synchronization primitives'' in HDK Technical Reference