4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
29 #include <sys/types.h>
31 #include <sys/taskqueue.h>
37 #define TASKQ_NAMELEN 31
41 struct taskqueue *tq_queue;
44 typedef struct taskq taskq_t;
45 typedef uintptr_t taskqid_t;
46 typedef void (task_func_t)(void *);
48 typedef struct taskq_ent {
49 struct task tqent_task;
50 task_func_t *tqent_func;
57 * Public flags for taskq_create(): bit range 0-15
59 #define TASKQ_PREPOPULATE 0x0001 /* Prepopulate with threads and data */
60 #define TASKQ_CPR_SAFE 0x0002 /* Use CPR safe protocol */
61 #define TASKQ_DYNAMIC 0x0004 /* Use dynamic thread scheduling */
62 #define TASKQ_THREADS_CPU_PCT 0x0008 /* number of threads as % of ncpu */
63 #define TASKQ_DC_BATCH 0x0010 /* Taskq uses SDC in batch mode */
66 * Flags for taskq_dispatch. TQ_SLEEP/TQ_NOSLEEP should be same as
67 * KM_SLEEP/KM_NOSLEEP.
69 #define TQ_SLEEP 0x00 /* Can block for memory */
70 #define TQ_NOSLEEP 0x01 /* cannot block for memory; may fail */
71 #define TQ_NOQUEUE 0x02 /* Do not enqueue if can't dispatch */
72 #define TQ_NOALLOC 0x04 /* cannot allocate memory; may fail */
73 #define TQ_FRONT 0x08 /* Put task at the front of the queue */
77 extern taskq_t *system_taskq;
79 void taskq_init(void);
80 void taskq_mp_init(void);
82 taskq_t *taskq_create(const char *, int, pri_t, int, int, uint_t);
83 taskq_t *taskq_create_instance(const char *, int, int, pri_t, int, int, uint_t);
84 taskq_t *taskq_create_proc(const char *, int, pri_t, int, int,
85 struct proc *, uint_t);
86 taskq_t *taskq_create_sysdc(const char *, int, int, int,
87 struct proc *, uint_t, uint_t);
88 taskqid_t taskq_dispatch(taskq_t *, task_func_t, void *, uint_t);
89 void taskq_dispatch_ent(taskq_t *, task_func_t, void *, uint_t,
91 void nulltask(void *);
92 void taskq_destroy(taskq_t *);
93 void taskq_wait(taskq_t *);
94 void taskq_suspend(taskq_t *);
95 int taskq_suspended(taskq_t *);
96 void taskq_resume(taskq_t *);
97 int taskq_member(taskq_t *, kthread_t *);
105 #endif /* _SYS_TASKQ_H */