1 .\" $NetBSD: workqueue.9,v 1.7 2009/08/03 23:29:19 rmind Exp $
3 .\" Copyright (c)2005 YAMAMOTO Takashi,
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 .\" ------------------------------------------------------------
31 .\" ------------------------------------------------------------
34 .Nd simple do-it-in-thread-context framework
35 .\" ------------------------------------------------------------
38 .\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
40 .Fn workqueue_create \
41 "struct workqueue **wqp" "const char *name" \
42 "void (*func)(struct work *, void *)" "void *arg" \
43 "pri_t prio" "int ipl" "int flags"
44 .\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
46 .Fn workqueue_enqueue \
47 "struct workqueue *wq" "struct work *wk" "struct cpu_info *ci"
48 .\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
50 .Fn workqueue_destroy \
51 "struct workqueue *wq"
52 .\" ------------------------------------------------------------
56 utility routines are provided to defer work which is needed to be
57 processed in a thread context.
59 .\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
62 It takes the following arguments:
65 Specify where to store the created workqueue.
67 The name of the workqueue.
69 The function to be called for each
72 An argument to be passed as a second argument of
75 The process priority to be used when sleeping to wait requests.
77 The highest IPL at which this workqueue is used.
79 The value of 0 indicates a standard create operation, however the following
80 flags may be bitwise ORed together:
81 .Bl -tag -width WQ_MPSAFE
83 Specifies that the workqueue is multiprocessor safe and does its own locking,
84 otherwise the kernel lock will be held while work will be processed.
86 Specifies that the workqueue should have a separate queue for each CPU,
87 thus the work could be enqueued on concrete CPUs.
91 .\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
100 flag was set on workqueue creation, the
102 argument may be used to specify the CPU on which the work should
106 then work will be enqueued on the current CPU.
114 The enqueued work will be processed in a thread context.
115 A work must not be enqueued again until the callback is called by
120 .\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
121 .Fn workqueue_destroy
122 destroys a workqueue and frees associated resources.
123 The caller should ensure that the workqueue has no work enqueued beforehand.
124 .\" ------------------------------------------------------------
127 returns 0 on success.
128 Otherwise, it returns an
130 .\" ------------------------------------------------------------
132 This section describes places within the
134 source tree where actual code implementing the
138 All pathnames are relative to
143 subsystem is implemented within the file
144 .Pa sys/kern/subr_workqueue.c .
145 .\" ------------------------------------------------------------