61 * (3) Some tasks may block for a long time, and this should not block other
62 * tasks in the queue.
63 *
64 * To provide useful service in such cases we define a "dynamic task queue"
65 * which has an individual thread for each of the tasks. These threads are
66 * dynamically created as they are needed and destroyed when they are not in
67 * use. The API for managing task pools is the same as for managing task queues
68 * with the exception of a taskq creation flag TASKQ_DYNAMIC which tells that
69 * dynamic task pool behavior is desired.
70 *
71 * Dynamic task queues may also place tasks in the normal queue (called "backing
72 * queue") when task pool runs out of resources. Users of task queues may
73 * disallow such queued scheduling by specifying TQ_NOQUEUE in the dispatch
74 * flags.
75 *
76 * The backing task queue is also used for scheduling internal tasks needed for
77 * dynamic task queue maintenance.
78 *
79 * INTERFACES ==================================================================
80 *
81 * taskq_t *taskq_create(name, nthreads, pri, minalloc, maxall, flags);
82 *
83 * Create a taskq with specified properties.
84 * Possible 'flags':
85 *
86 * TASKQ_DYNAMIC: Create task pool for task management. If this flag is
87 * specified, 'nthreads' specifies the maximum number of threads in
88 * the task queue. Task execution order for dynamic task queues is
89 * not predictable.
90 *
91 * If this flag is not specified (default case) a
92 * single-list task queue is created with 'nthreads' threads
93 * servicing it. Entries in this queue are managed by
94 * taskq_ent_alloc() and taskq_ent_free() which try to keep the
95 * task population between 'minalloc' and 'maxalloc', but the
96 * latter limit is only advisory for TQ_SLEEP dispatches and the
97 * former limit is only advisory for TQ_NOALLOC dispatches. If
98 * TASKQ_PREPOPULATE is set in 'flags', the taskq will be
99 * prepopulated with 'minalloc' task structures.
100 *
101 * Since non-DYNAMIC taskqs are queues, tasks are guaranteed to be
111 * number of threads in the taskq in response to CPU online
112 * and offline events, to keep the ratio. nthreads must be in
113 * the range [0,100].
114 *
115 * The calculation used is:
116 *
117 * MAX((ncpus_online * percentage)/100, 1)
118 *
119 * This flag is not supported for DYNAMIC task queues.
120 * This flag is not compatible with TASKQ_CPR_SAFE.
121 *
122 * TASKQ_CPR_SAFE: This flag specifies that users of the task queue will
123 * use their own protocol for handling CPR issues. This flag is not
124 * supported for DYNAMIC task queues. This flag is not compatible
125 * with TASKQ_THREADS_CPU_PCT.
126 *
127 * The 'pri' field specifies the default priority for the threads that
128 * service all scheduled tasks.
129 *
130 * taskq_t *taskq_create_instance(name, instance, nthreads, pri, minalloc,
131 * maxall, flags);
132 *
133 * Like taskq_create(), but takes an instance number (or -1 to indicate
134 * no instance).
135 *
136 * taskq_t *taskq_create_proc(name, nthreads, pri, minalloc, maxall, proc,
137 * flags);
138 *
139 * Like taskq_create(), but creates the taskq threads in the specified
140 * system process. If proc != &p0, this must be called from a thread
141 * in that process.
142 *
143 * taskq_t *taskq_create_sysdc(name, nthreads, minalloc, maxall, proc,
144 * dc, flags);
145 *
146 * Like taskq_create_proc(), but the taskq threads will use the
147 * System Duty Cycle (SDC) scheduling class with a duty cycle of dc.
148 *
149 * void taskq_destroy(tap):
150 *
151 * Waits for any scheduled tasks to complete, then destroys the taskq.
152 * Caller should guarantee that no new tasks are scheduled in the closing
153 * taskq.
154 *
155 * taskqid_t taskq_dispatch(tq, func, arg, flags):
156 *
157 * Dispatches the task "func(arg)" to taskq. The 'flags' indicates whether
158 * the caller is willing to block for memory. The function returns an
159 * opaque value which is zero iff dispatch fails. If flags is TQ_NOSLEEP
160 * or TQ_NOALLOC and the task can't be dispatched, taskq_dispatch() fails
161 * and returns (taskqid_t)0.
162 *
163 * ASSUMES: func != NULL.
|
61 * (3) Some tasks may block for a long time, and this should not block other
62 * tasks in the queue.
63 *
64 * To provide useful service in such cases we define a "dynamic task queue"
65 * which has an individual thread for each of the tasks. These threads are
66 * dynamically created as they are needed and destroyed when they are not in
67 * use. The API for managing task pools is the same as for managing task queues
68 * with the exception of a taskq creation flag TASKQ_DYNAMIC which tells that
69 * dynamic task pool behavior is desired.
70 *
71 * Dynamic task queues may also place tasks in the normal queue (called "backing
72 * queue") when task pool runs out of resources. Users of task queues may
73 * disallow such queued scheduling by specifying TQ_NOQUEUE in the dispatch
74 * flags.
75 *
76 * The backing task queue is also used for scheduling internal tasks needed for
77 * dynamic task queue maintenance.
78 *
79 * INTERFACES ==================================================================
80 *
81 * taskq_t *taskq_create(name, nthreads, pri, minalloc, maxalloc, flags);
82 *
83 * Create a taskq with specified properties.
84 * Possible 'flags':
85 *
86 * TASKQ_DYNAMIC: Create task pool for task management. If this flag is
87 * specified, 'nthreads' specifies the maximum number of threads in
88 * the task queue. Task execution order for dynamic task queues is
89 * not predictable.
90 *
91 * If this flag is not specified (default case) a
92 * single-list task queue is created with 'nthreads' threads
93 * servicing it. Entries in this queue are managed by
94 * taskq_ent_alloc() and taskq_ent_free() which try to keep the
95 * task population between 'minalloc' and 'maxalloc', but the
96 * latter limit is only advisory for TQ_SLEEP dispatches and the
97 * former limit is only advisory for TQ_NOALLOC dispatches. If
98 * TASKQ_PREPOPULATE is set in 'flags', the taskq will be
99 * prepopulated with 'minalloc' task structures.
100 *
101 * Since non-DYNAMIC taskqs are queues, tasks are guaranteed to be
111 * number of threads in the taskq in response to CPU online
112 * and offline events, to keep the ratio. nthreads must be in
113 * the range [0,100].
114 *
115 * The calculation used is:
116 *
117 * MAX((ncpus_online * percentage)/100, 1)
118 *
119 * This flag is not supported for DYNAMIC task queues.
120 * This flag is not compatible with TASKQ_CPR_SAFE.
121 *
122 * TASKQ_CPR_SAFE: This flag specifies that users of the task queue will
123 * use their own protocol for handling CPR issues. This flag is not
124 * supported for DYNAMIC task queues. This flag is not compatible
125 * with TASKQ_THREADS_CPU_PCT.
126 *
127 * The 'pri' field specifies the default priority for the threads that
128 * service all scheduled tasks.
129 *
130 * taskq_t *taskq_create_instance(name, instance, nthreads, pri, minalloc,
131 * maxalloc, flags);
132 *
133 * Like taskq_create(), but takes an instance number (or -1 to indicate
134 * no instance).
135 *
136 * taskq_t *taskq_create_proc(name, nthreads, pri, minalloc, maxalloc, proc,
137 * flags);
138 *
139 * Like taskq_create(), but creates the taskq threads in the specified
140 * system process. If proc != &p0, this must be called from a thread
141 * in that process.
142 *
143 * taskq_t *taskq_create_sysdc(name, nthreads, minalloc, maxalloc, proc,
144 * dc, flags);
145 *
146 * Like taskq_create_proc(), but the taskq threads will use the
147 * System Duty Cycle (SDC) scheduling class with a duty cycle of dc.
148 *
149 * void taskq_destroy(tap):
150 *
151 * Waits for any scheduled tasks to complete, then destroys the taskq.
152 * Caller should guarantee that no new tasks are scheduled in the closing
153 * taskq.
154 *
155 * taskqid_t taskq_dispatch(tq, func, arg, flags):
156 *
157 * Dispatches the task "func(arg)" to taskq. The 'flags' indicates whether
158 * the caller is willing to block for memory. The function returns an
159 * opaque value which is zero iff dispatch fails. If flags is TQ_NOSLEEP
160 * or TQ_NOALLOC and the task can't be dispatched, taskq_dispatch() fails
161 * and returns (taskqid_t)0.
162 *
163 * ASSUMES: func != NULL.
|