2 .\" Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved.
3 .\" Copyright 1989 AT&T
4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 .TH TASKQ 9F "Jul 25, 2015"
9 taskq, ddi_taskq_create, ddi_taskq_destroy, ddi_taskq_dispatch, ddi_taskq_wait,
10 ddi_taskq_suspend, taskq_suspended, ddi_taskq_resume \- Kernel task queue
15 #include <sys/sunddi.h>
17 \fBddi_taskq_t *\fR\fBddi_taskq_create\fR(\fBdev_info_t *\fR\fIdip\fR, \fBconst char *\fR\fIname\fR,
18 \fBint\fR \fInthreads\fR, \fBpri_t\fR \fIpri\fR, \fBuint_t\fR \fIcflags\fR);
23 \fBvoid\fR \fBddi_taskq_destroy\fR(\fBddi_taskq_t *\fR\fItq\fR);
28 \fBint\fR \fBddi_taskq_dispatch\fR(\fBddi_taskq_t *\fR\fItq\fR, \fBvoid (*\fR \fIfunc)\fR(void *),
29 \fBvoid *\fR\fIarg\fR, \fBuint_t\fR \fIdflags\fR);
34 \fBvoid\fR \fBddi_taskq_wait\fR(\fBddi_taskq_t *\fR\fItq\fR);
39 \fBvoid\fR \fBddi_taskq_suspend\fR(\fBddi_taskq_t *\fR\fItq\fR);
44 \fBboolean_t\fR \fBddi_taskq_suspended\fR(\fBddi_taskq_t *\fR\fItq\fR);
49 \fBvoid\fR \fBddi_taskq_resume\fR(\fBddi_taskq_t *\fR\fItq\fR);
54 Solaris DDI specific (Solaris DDI)
61 Pointer to the device's dev_info structure. May be NULL for kernel
62 modules that do not have an associated dev_info structure.
71 Descriptive string. Only alphanumeric characters can be used in name
72 and spaces are not allowed. The name should be unique.
81 Number of threads servicing the task queue. Note that the request ordering is
82 guaranteed (tasks are processed in the order scheduled) if the \fBtaskq\fR is
83 created with a single servicing thread.
92 Priority of threads servicing the task queue. Drivers and modules should
93 specify TASKQ_DEFAULTPRI.
102 Should pass 0 as flags.
111 Callback function to call.
120 Argument to the callback function.
129 Possible \fIdflags\fR are:
136 Allow sleeping (blocking) until memory is available.
145 Return DDI_FAILURE immediately if memory is not available.
156 Pointer to a task queue (ddi_taskq_t *).
165 Pointer to a thread structure.
170 A kernel task queue is a mechanism for general-purpose asynchronous task
171 scheduling that enables tasks to be performed at a later time by another
172 thread. There are several reasons why you may utilize asynchronous task
177 You have a task that isn't time-critical, but a current code path that is.
182 You have a task that may require grabbing locks that a thread already holds.
187 You have a task that needs to block (for example, to wait for memory), but you
188 have a thread that cannot block in its current context.
193 You have a code path that can't complete because of a specific condition,
194 but also can't sleep or fail. In this case, the task is immediately queued and
195 then is executed after the condition disappears.
200 A task queue is just a simple way to launch multiple tasks in parallel.
204 A task queue consists of a list of tasks, together with one or more threads to
205 service the list. If a task queue has a single service thread, all tasks are
206 guaranteed to execute in the order they were dispatched. Otherwise they can be
207 executed in any order. Note that since tasks are placed on a list, execution of
208 one task should not depend on the execution of another task or a deadlock
212 The \fBddi_taskq_create()\fR function creates a task queue instance.
215 The \fBddi_taskq_dispatch()\fR function places \fBtaskq\fR on the list for
216 later execution. The \fIdflag\fR argument specifies whether it is allowed sleep
217 waiting for memory. DDI_SLEEP dispatches can sleep and are guaranteed to
218 succeed. DDI_NOSLEEP dispatches are guaranteed not to sleep but may fail
219 (return \fBDDI_FAILURE\fR) if resources are not available.
222 The \fBddi_taskq_destroy()\fR function waits for any scheduled tasks to
223 complete, then destroys the \fBtaskq\fR. The caller should guarantee that no
224 new tasks are scheduled for the closing \fBtaskq\fR.
227 The \fBddi_taskq_wait()\fR function waits for all previously scheduled tasks to
228 complete. Note that this function does not stop any new task dispatches.
231 The \fBddi_taskq_suspend()\fR function suspends all task execution until
232 \fBddi_taskq_resume()\fR is called. Although \fBddi_taskq_suspend()\fR attempts
233 to suspend pending tasks, there are no guarantees that they will be suspended.
234 The only guarantee is that all tasks dispatched after \fBddi_taskq_suspend()\fR
235 will not be executed. Because it will trigger a deadlock, the
236 \fBddi_taskq_suspend()\fR function should never be called by a task executing
240 The \fBddi_taskq_suspended()\fR function returns \fBB_TRUE\fR if \fBtaskq\fR is
241 suspended, and \fBB_FALSE\fR otherwise. It is intended to ASSERT that the task
245 The \fBddi_taskq_resume()\fR function resumes task queue execution.
248 The \fBddi_taskq_create()\fR function creates an opaque handle that is used for
249 all other \fBtaskq\fR operations. It returns a \fBtaskq\fR pointer on success
253 The \fBddi_taskq_dispatch()\fR function returns \fBDDI_FAILURE\fR if it can't
254 dispatch a task and returns \fBDDI_SUCCESS\fR if dispatch succeeded.
257 The \fBddi_taskq_suspended()\fR function returns \fBB_TRUE\fR if \fBtaskq\fR is
258 suspended. Otherwise \fBB_FALSE\fR is returned.
261 All functions may be called from the user or kernel contexts.
264 Addtionally, the \fBddi_taskq_dispatch\fR function may be called from the
265 interrupt context only if the DDI_NOSLEEP flag is set.