p
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.Fn workqueue_create
creates a workqueue.
It takes the following arguments:
l -tag -width flags t Fa wqp Specify where to store the created workqueue.
t Fa name The name of the workqueue.
t Fa func The function to be called for each
.Fa work .
t Fa arg An argument to be passed as a second argument of
.Fa func .
t Fa prio The priority level for the worker threads.
t Fa ipl The highest IPL at which this workqueue is used.
t Fa flags The value of 0 indicates a standard create operation, however the following
flags may be bitwise ORed together:
l -tag -width WQ_MPSAFE t Dv WQ_FPU Specifies that the kthread must be allowed to use any machine-dependent
per-CPU floating-point units or SIMD vector units, as in
.Xr kthread_fpu_enter 9 / Xr kthread_fpu_exit 9 ,
when it executes the worker function.
t Dv WQ_MPSAFE Specifies that the workqueue is multiprocessor safe and does its own locking;
otherwise the kernel lock will be held while processing work.
t Dv WQ_PERCPU Specifies that the workqueue should have a separate queue for each CPU,
thus the work could be enqueued on concrete CPUs.
.El
.El
p
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.Fn workqueue_enqueue
enqueues the work
.Fa wk
into the workqueue
.Fa wq .
p If the .Dv WQ_PERCPU flag was set on workqueue creation, the .Fa ci argument may be used to specify the CPU on which the work should be enqueued. Also it may be .Dv NULL , then work will be enqueued on the current CPU. If .Dv WQ_PERCPU flag was not set, .Fa ci must be .Dv NULL .
p The enqueued work will be processed in a thread context. A work must not be enqueued again until the callback is called by the .Nm framework.
p
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.Fn workqueue_wait
waits for a specified work
.Fa wk
on the workqueue
.Fa wq
to finish.
The caller must ensure that
.Fa wk
will not be enqueued to the workqueue again until after
.Fn workqueue_wait
returns.
p
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.Fn workqueue_destroy
destroys a workqueue and frees associated resources.
The caller should ensure that the workqueue has no work enqueued beforehand.
------------------------------------------------------------
.Sh RETURN VALUES
.Fn workqueue_create
returns 0 on success.
Otherwise, it returns an
.Xr errno 2 .
------------------------------------------------------------
.Sh CODE REFERENCES
The
.Nm
subsystem is implemented within the file
a sys/kern/subr_workqueue.c .
------------------------------------------------------------
.Sh SEE ALSO
.Xr callout 9 ,
.Xr condvar 9 ,
.Xr kthread 9 ,
.Xr softint 9