SPL(9)

NAME
spl, spl0, splbio, splclock, splhigh, splimp, splnet, splsched, splserial, splsoftclock, splsoftnet, splsoftserial, splstatclock, spltty, splx - modify system interrupt priority level

SYNOPSIS
#include <machine/intr.h>
int
splhigh(void);
int
splsched(void);
int
splserial(void);
int
splclock(void);
int
splstatclock(void);
int
splimp(void);
int
spltty(void);
int
splsoftserial(void);
int
splnet(void);
int
splbio(void);
int
splsoftnet(void);
int
splsoftclock(void);
int
spl0(void);
void
splx(int s);

DESCRIPTION
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 (e.g. spltty() blocks interrupts of priority less than or equal to IPL_TTY). The code may then safely access variables or data structures which are read or modified by interrupt service routines that run at the named level.

A spl function exists for each distinct priority level which can exist in the system. These functions 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. Soft interrupts are generated by callouts, and are called from the kernel's periodic timer interrupt service routine.

In order of highest to lowest priority, the priority-raising functions are:

splhigh()
    blocks all hard and soft interrupts. It is used for code that cannot tolerate any interrupts, like hardware context switching code and the ddb(4) in-kernel debugger.

splserial()
    blocks hard interrupts from serial interfaces. Code running at this level may not access the tty subsystem.

splsched()
    blocks interrupts that may access scheduler data structures. Code running at or above this level may not call sleep(), tsleep(), or wakeup(), nor may it post signals.

splclock()
    blocks the hardware clock interrupt. It is used by hardclock() 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.

splimp()
    blocks hard interrupts from all devices that are allowed to use the kernel malloc(9). That includes all disk, network, and tty device interrupts.

spltty()
    blocks hard interrupts from TTY devices.

splsoftserial()
    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.

Two functions lower the system priority level. They are:

splsoftclock()
    unblocks all interrupts but the soft clock interrupt.

spl0()
    unblocks all interrupts.

The splx() function restores the system priority level to the one encoded in s, which must be a value previously returned by one of the other spl functions.