|TASK_ADD(9)||Kernel Developer's Manual||TASK_ADD(9)|
struct taskq *
char *name, unsigned int
task *t, void (*fn)(void
*, void *), void
taskq *tq, struct task
taskq *tq, struct task
extern struct taskq *const systq;
extern struct taskq *const systqmp;
(*fn)(void *, void *),
taskq_create() allocates a taskq and a set
of threads to be used to complete work that would be inappropriate for the
shared system taskq. The name argument specifies the
name of the kernel threads that are created to service the work on the
taskq. nthreads specifies the number of threads that
will be created to handle the work. ipl specifies the
highest interrupt protection level at which
will be called against the created taskq. See
spl(9) for a list of the
taskq_destroy() causes the resources
associated with a previously created taskq to be freed. It will wait till
all the tasks in the work queue are completed before returning. Calling
taskq_destroy() against the system taskq is an error
and will lead to undefined behaviour or a system fault.
It is the responsibility of the caller to provide the
task_del() functions with pre-allocated task
task_set() prepares the task structure
t to be used in future calls to
t will be prepared to call the function
fn with the arguments specified by
arg1 and arg2. Once initialised,
the t structure can be used repeatedly in calls to
and does not need to be reinitialised unless the function called and/or its
argument must change.
task_add() schedules the execution of the
work specified by the task structure t on the
tq taskq. The task structure must already be
task_del() will remove the task structure
t from the taskq tq. If the work
was already executed or has not been added to the taskq, the call will have
no effect. Calling
task_del() against a different
taskq than the one given in a previous call to
task_add() is an error and will lead to undefined
The kernel provides two system taskqs: systq, which executes while holding the kernel lock, and systqmp, which does not hold the kernel lock during execution. They can both be used by any subsystem for short lived tasks. They are serviced by a single thread and can therefore provide predictable ordering of work. Work can be scheduled on the system taskqs from callers at or below IPL_HIGH.
A task declaration can be initialised with the
TASK_INITIALIZER() macro. The task will be prepared
to call the function specified by the fn argument with
the void * arguments given in
arg1 and arg2.
taskq_destroy() can be called during autoconf, or from process context.
task_del() can be called during autoconf, from process context, or from interrupt context.
taskq_create() returns a pointer to a taskq structure on success or
task_add() will return 1 if the task
t was added to the taskq tq or 0
if the task was already queued.
task_del() will return 1 if the task
t was removed from the taskq tq
or 0 if the task was not already on the queue.
|June 11, 2014||OpenBSD-5.6|