SPL(9) BSD Kernel Manual SPL(9)
spl - modify system interrupt priority level
#include <machine/intr.h> int splhigh(void); int splserial(void); int splsched(void); int splclock(void); int splstatclock(void); int splvm(void); int spltty(void); int splsofttty(void); int splnet(void); int splbio(void); int splsoftnet(void); int splsoftclock(void); int spllowersoftclock(void); int spl0(void); void splx(int s); void splassert(int s);
These functions raise and lower the system priority level. They are used by kernel code to block interrupts with priority less than or equal to the named level (i.e., spltty() blocks interrupts of priority less than or equal to IPL_TTY). The code may then safely access variables and data structures which are used by kernel code that runs at an equal or lower priority level. An spl function exists for each distinct priority level which can exist in the system. These macros and the corresponding priority levels are used for various defined purposes, and may be divided into two main types: hard and soft. Hard interrupts are generated by hardware devices, while soft interrupts are generated by callouts and called from the kernel's periodic timer interrupt service routine. In order of highest to lowest priority, the priority-raising macros are: splhigh() blocks all hard and soft interrupts. It is used for code that cannot tolerate any interrupts, like hardware con- text switching code and the ddb(4) in-kernel debugger. splserial() blocks hard interrupts from serial interfaces. Code run- ning at this level may not access the tty subsystem. splsched() blocks interrupts that may access scheduler data struc- tures. Code running at or above this level may not call sleep(), tsleep(), or wakeup(), nor may it post signals. Note that "running" means invoked by an interrupt handler that operates at this level or higher. Kernel code that operates in the context of a process and has called splhigh() for blocking purposes can use sleep(), tsleep(), or wakeup(). splclock() blocks the hardware clock interrupt. It is used by hard- clock() to update kernel and process times, and must be used by any other code that accesses time-related data. splstatclock() blocks the hardware statistics clock interrupt. It is used by statclock() to update kernel profiling and other statistics, and must be used by any code that accesses that data. This level is identical to splclock() if there is no separate statistics clock. splvm() blocks hard interrupts from all devices that are allowed to use the kernel malloc(9). That includes all disk, net- work, and tty device interrupts. spltty() blocks hard interrupts from TTY devices. splsofttty() blocks soft interrupts generated by serial devices. splnet() blocks hard interrupts from network interfaces. splbio() blocks hard interrupts from disks and other mass-storage devices. splsoftnet() blocks soft network interrupts. splsoftclock() blocks soft clock interrupts. Two macros lower the system priority level. They are: spllowersoftclock() unblocks all interrupts but the soft clock inter- rupt. spl0() unblocks all interrupts. The splx() macro restores the system priority level to the one encoded in s, which must be a value previously returned by one of the other spl mac- ros. The splassert() function checks that the system is running at a certain priority level. The argument s should be one of these constants: IPL_STATCLOCK IPL_CLOCK IPL_VM IPL_BIO IPL_TTY IPL_NET IPL_SOFTNET IPL_SOFTCLOCK IPL_NONE The splassert() function is optional and is not necessarily implemented on all architectures nor enabled in all kernel configurations. It checks the current system priority level to see if it's at least at the level specified in the argument s. If possible, it also checks if it hasn't been called from an interrupt handler with a level higher than the one requested, which must be an error (if some code is protected from IPL_SOFTNET interrupts, but accessed from an IPL_NET interrupt, it must be a design error in the code). The behavior of the splassert() function is controlled by the kern.splassert sysctl(8). Valid values for it are: 0 disable error checking 1 print a message if an error is detected 2 print a message and a stack trace if possible 3 like 2 but also drop into the kernel debugger Any other value causes a system panic on errors. MirOS BSD #10-current March 11, 1997 2
Generated on 2014-04-02 20:57:59 by $MirOS: src/scripts/roff2htm,v 1.79 2014/02/10 00:36:11 tg Exp $
These manual pages and other documentation are copyrighted by their respective writers;
their source is available at our CVSweb,
AnonCVS, and other mirrors. The rest is Copyright © 2002‒2014 The MirOS Project, Germany.
This product includes material provided by Thorsten Glaser.
This manual page’s HTML representation is supposed to be valid XHTML/1.1; if not, please send a bug report – diffs preferred.