Interrupt Handlers in FreeBSD

Now that you know how to register an interrupt handler, let’s discuss how interrupt handlers are implemented.

In FreeBSD, interrupt handlers are composed of a filter routine, an ithread routine, or both. A filter routine executes in primary interrupt context (that is, it does not have its own context). Thus, it cannot block or context switch, and it can use only spin mutexes for synchronization. Due to these constraints, filter routines are typically used only with devices that require a nonpreemptive interrupt handler.

A filter routine may either completely handle an interrupt or defer the computationally expensive work to its associated ithread routine, assuming it has one. Table 8-2 details the values that a filter routine can return.

Table 8-2. Filter Routine Return Values

Constant

Description

FILTER_STRAY

Indicates that the filter routine can’t handle this interrupt; this value is equivalent to an error code.

FILTER_HANDLED

Indicates that the interrupt has been completely handled; this value is equivalent to a success code.

FILTER_SCHEDULE_THREAD

Schedules the ithread routine to execute; this value can be returned if and only if the filter routine has an associated ithread routine.

An ithread routine, unlike a filter routine, executes in its own thread context. You can do whatever you want in an ithread routine, except voluntarily context switch (that is, sleep) or wait on a condition variable. Because filter routines are nonpreemptive, most interrupt handlers in FreeBSD are just ithread routines.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.67.40