These functions are used to register and schedule software interrupt handlers. Software interrupt handlers are attached to a software interrupt thread, just as hardware interrupt handlers are attached to a hardware interrupt thread. Multiple handlers can be attached to the same thread. Software interrupt handlers can be used to queue up less critical processing inside of hardware interrupt handlers so that the work can be done at a later time. Software interrupt threads are different from other kernel threads in that they are treated as an interrupt thread. This means that time spent executing these threads is counted as interrupt time, and that they can be run via a lightweight context switch.
The swi_add function is used to register a new software interrupt handler. The ithdp argument is an optional pointer to a
.Vt struct ithd pointer. If this argument points to an existing software interrupt thread, then this handler will be attached to that thread. Otherwise a new thread will be created, and if ithdp is not NULL, then the pointer at that address to will be modified to point to the newly created thread. The name argument is used to associate a name with a specific handler. This name is appended to the name of the software interrupt thread that this handler is attached to. The handler argument is the function that will be executed when the handler is scheduled to run. The arg parameter will be passed in as the only parameter to handler when the function is executed. The pri value specifies the priority of this interrupt handler relative to other software interrupt handlers. If an interrupt thread is created, then this value is used as the vector, and the flags argument is used to specify the attributes of a handler such as INTR_MPSAFE. The cookiep argument points to a
.Vt void * cookie. This cookie will be set to a value that uniquely identifies this handler, and is used to schedule the handler for execution later on.
The swi_sched function is used to schedule an interrupt handler and its associated thread to run. The cookie argument specifies which software interrupt handler should be scheduled to run. The flags argument specifies how and when the handler should be run and is a mask of one or more of the following flags: