xref: /titanic_41/usr/src/uts/common/sys/taskq.h (revision 70025d765b044c6d8594bb965a2247a61e991a99)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_TASKQ_H
28 #define	_SYS_TASKQ_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.h>
33 #include <sys/thread.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 #define	TASKQ_NAMELEN	31
40 
41 typedef struct taskq taskq_t;
42 typedef uintptr_t taskqid_t;
43 typedef void (task_func_t)(void *);
44 
45 /*
46  * Public flags for taskq_create(): bit range 0-15
47  */
48 #define	TASKQ_PREPOPULATE	0x0001	/* Prepopulate with threads and data */
49 #define	TASKQ_CPR_SAFE		0x0002	/* Use CPR safe protocol */
50 #define	TASKQ_DYNAMIC		0x0004	/* Use dynamic thread scheduling */
51 
52 /*
53  * Flags for taskq_dispatch. TQ_SLEEP/TQ_NOSLEEP should be same as
54  * KM_SLEEP/KM_NOSLEEP.
55  */
56 #define	TQ_SLEEP	0x00	/* Can block for memory */
57 #define	TQ_NOSLEEP	0x01	/* cannot block for memory; may fail */
58 #define	TQ_NOQUEUE	0x02	/* Do not enqueue if can't dispatch */
59 #define	TQ_NOALLOC	0x04	/* cannot allocate memory; may fail */
60 
61 #ifdef _KERNEL
62 
63 extern taskq_t *system_taskq;
64 
65 extern void	taskq_init(void);
66 
67 extern taskq_t	*taskq_create(const char *, int, pri_t, int, int, uint_t);
68 extern taskq_t	*taskq_create_instance(const char *, int, int, pri_t, int,
69     int, uint_t);
70 extern taskqid_t taskq_dispatch(taskq_t *, task_func_t, void *, uint_t);
71 extern void	nulltask(void *);
72 extern void	taskq_destroy(taskq_t *);
73 extern void	taskq_wait(taskq_t *);
74 extern void	taskq_suspend(taskq_t *);
75 extern int	taskq_suspended(taskq_t *);
76 extern void	taskq_resume(taskq_t *);
77 extern int	taskq_member(taskq_t *, kthread_t *);
78 
79 #endif	/* _KERNEL */
80 
81 #ifdef	__cplusplus
82 }
83 #endif
84 
85 #endif	/* _SYS_TASKQ_H */
86