ithread_add_handler ithread_create ithread_destroy ithread_priority ithread_remove_handler ithread_schedule - kernel interrupt threads
The
ithread_create ();
function creates a new interrupt thread.
The
Fa ithread
argument points to an
Vt struct ithd
pointer that will point to the newly created thread upon success.
The
Fa vector
argument specifies the interrupt source to associate this thread with.
The
Fa flags
argument is a mask of properties of this thread.
The only valid flag currently for
ithread_create ();
is
IT_SOFT
to specify that this interrupt thread is a software interrupt.
The
Fa enable
and
Fa disable
arguments specify optional functions used to enable and disable this
interrupt thread's interrupt source.
The functions receive the vector corresponding to the thread's interrupt
source as their only argument.
The remaining arguments form a
printf(9)
argument list that is used to build the base name of the new ithread.
The full name of an interrupt thread is formed by concatenating the base
name of an interrupt thread with the names of all of its interrupt handlers.
The
ithread_destroy ();
function destroys a previously created interrupt thread by releasing its
resources and arranging for the backing kernel thread to terminate.
An interrupt thread can only be destroyed if it has no handlers remaining.
The
ithread_add_handler ();
function adds a new handler to an existing interrupt thread specified by
Fa ithread .
The
Fa name
argument specifies a name for this handler.
The
Fa handler
and
Fa arg
arguments provide the function to execute for this handler and an argument
to pass to it.
The
Fa pri
argument specifies the priority of this handler and is used both in sorting
it in relation to the other handlers for this thread and to specify the
priority of the backing kernel thread.
The
Fa flags
argument can be used to specify properties of this handler as defined in
In sys/bus.h .
If
Fa cookiep
is not
NULL
then it will be assigned a cookie that can be used later to remove this
handler.
The
ithread_remove_handler ();
removes a handler from an interrupt thread.
The
Fa cookie
argument specifies the handler to remove from its thread.
The
ithread_schedule ();
function schedules an interrupt thread to run.
If the
Fa do_switch
argument is non-zero and the interrupt thread is idle, then a context switch
will be forced after putting the interrupt thread on the run queue.
The
ithread_priority ();
function translates the
INTR_TYPE_*
interrupt flags into interrupt handler priorities.
The interrupt flags not related to the type of a particular interrupt (INTR_TYPE_* ) can be used to specify additional properties of both hardware and software interrupt handlers. The INTR_EXCL flag specifies that this handler cannot share an interrupt thread with another handler. The INTR_FAST flag specifies that when this handler is executed, it should be run immediately rather than being run asynchronously when its interrupt thread is scheduled to run. The INTR_FAST flag implies INTR_EXCL The INTR_MPSAFE flag specifies that this handler is MP safe in that it does not need the Giant mutex to be held while it is executed. The INTR_ENTROPY flag specifies that the interrupt source this handler is tied to is a good source of entropy, and thus that entropy should be gathered when an interrupt from the handler's source triggers. Presently, the INTR_FAST and INTR_ENTROPY flags are not valid for software interrupt handlers.
It is not permitted to sleep in an interrupt thread; hence, any memory or zone allocations in an interrupt thread should be specified with the M_NOWAIT flag set. Any allocation errors must be handled thereafter.
int swi_add(struct ithd **ithdp, const char *name, driver_intr_t handler, void *arg, int pri, enum intr_type flags, void **cookiep) { struct proc *p; struct ithd *ithd; int error; if (flags & (INTR_FAST | INTR_ENTROPY)) return (EINVAL); ithd = (ithdp != NULL) ? *ithdp : NULL; if (ithd != NULL) { if ((ithd->it_flags & IT_SOFT) == 0) return(EINVAL); } else { error = ithread_create(&ithd, pri, IT_SOFT, NULL, NULL, "swi%d:", pri); if (error) return (error); if (ithdp != NULL) *ithdp = ithd; } return (ithread_add_handler(ithd, name, handler, arg, pri + PI_SOFT, flags, cookiep)); }
The
ithread_create ();
function will fail if:
The
ithread_destroy ();
function will fail if:
The
ithread_remove_handler ();
function will fail if:
The
ithread_schedule ();
function will fail if:
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |