xref: /titanic_52/usr/src/uts/common/sys/taskq.h (revision 55f5292c612446ce6f93ddd248c0019b5974618b)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_TASKQ_H
27 #define	_SYS_TASKQ_H
28 
29 #include <sys/types.h>
30 #include <sys/thread.h>
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #define	TASKQ_NAMELEN	31
37 
38 typedef struct taskq taskq_t;
39 typedef uintptr_t taskqid_t;
40 typedef void (task_func_t)(void *);
41 
42 /*
43  * Public flags for taskq_create(): bit range 0-15
44  */
45 #define	TASKQ_PREPOPULATE	0x0001	/* Prepopulate with threads and data */
46 #define	TASKQ_CPR_SAFE		0x0002	/* Use CPR safe protocol */
47 #define	TASKQ_DYNAMIC		0x0004	/* Use dynamic thread scheduling */
48 #define	TASKQ_THREADS_CPU_PCT	0x0008	/* number of threads as % of ncpu */
49 
50 /*
51  * Flags for taskq_dispatch. TQ_SLEEP/TQ_NOSLEEP should be same as
52  * KM_SLEEP/KM_NOSLEEP.
53  */
54 #define	TQ_SLEEP	0x00	/* Can block for memory */
55 #define	TQ_NOSLEEP	0x01	/* cannot block for memory; may fail */
56 #define	TQ_NOQUEUE	0x02	/* Do not enqueue if can't dispatch */
57 #define	TQ_NOALLOC	0x04	/* cannot allocate memory; may fail */
58 
59 #ifdef _KERNEL
60 
61 extern taskq_t *system_taskq;
62 
63 extern void	taskq_init(void);
64 extern void	taskq_mp_init(void);
65 
66 extern taskq_t	*taskq_create(const char *, int, pri_t, int, int, uint_t);
67 extern taskq_t	*taskq_create_instance(const char *, int, int, pri_t, int,
68     int, uint_t);
69 extern taskqid_t taskq_dispatch(taskq_t *, task_func_t, void *, uint_t);
70 extern void	nulltask(void *);
71 extern void	taskq_destroy(taskq_t *);
72 extern void	taskq_wait(taskq_t *);
73 extern void	taskq_suspend(taskq_t *);
74 extern int	taskq_suspended(taskq_t *);
75 extern void	taskq_resume(taskq_t *);
76 extern int	taskq_member(taskq_t *, kthread_t *);
77 
78 #endif	/* _KERNEL */
79 
80 #ifdef	__cplusplus
81 }
82 #endif
83 
84 #endif	/* _SYS_TASKQ_H */
85