xref: /onnv-gate/usr/src/uts/common/sys/taskq.h (revision 11173:87f3734e64df)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
59515SJonathan.Adams@Sun.COM  * Common Development and Distribution License (the "License").
69515SJonathan.Adams@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
229515SJonathan.Adams@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_TASKQ_H
270Sstevel@tonic-gate #define	_SYS_TASKQ_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #include <sys/types.h>
300Sstevel@tonic-gate #include <sys/thread.h>
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #ifdef	__cplusplus
330Sstevel@tonic-gate extern "C" {
340Sstevel@tonic-gate #endif
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #define	TASKQ_NAMELEN	31
370Sstevel@tonic-gate 
380Sstevel@tonic-gate typedef struct taskq taskq_t;
390Sstevel@tonic-gate typedef uintptr_t taskqid_t;
400Sstevel@tonic-gate typedef void (task_func_t)(void *);
410Sstevel@tonic-gate 
42*11173SJonathan.Adams@Sun.COM struct proc;
43*11173SJonathan.Adams@Sun.COM 
440Sstevel@tonic-gate /*
450Sstevel@tonic-gate  * Public flags for taskq_create(): bit range 0-15
460Sstevel@tonic-gate  */
470Sstevel@tonic-gate #define	TASKQ_PREPOPULATE	0x0001	/* Prepopulate with threads and data */
480Sstevel@tonic-gate #define	TASKQ_CPR_SAFE		0x0002	/* Use CPR safe protocol */
490Sstevel@tonic-gate #define	TASKQ_DYNAMIC		0x0004	/* Use dynamic thread scheduling */
509515SJonathan.Adams@Sun.COM #define	TASKQ_THREADS_CPU_PCT	0x0008	/* number of threads as % of ncpu */
51*11173SJonathan.Adams@Sun.COM #define	TASKQ_DC_BATCH		0x0010	/* Taskq uses SDC in batch mode */
520Sstevel@tonic-gate 
530Sstevel@tonic-gate /*
540Sstevel@tonic-gate  * Flags for taskq_dispatch. TQ_SLEEP/TQ_NOSLEEP should be same as
550Sstevel@tonic-gate  * KM_SLEEP/KM_NOSLEEP.
560Sstevel@tonic-gate  */
570Sstevel@tonic-gate #define	TQ_SLEEP	0x00	/* Can block for memory */
580Sstevel@tonic-gate #define	TQ_NOSLEEP	0x01	/* cannot block for memory; may fail */
590Sstevel@tonic-gate #define	TQ_NOQUEUE	0x02	/* Do not enqueue if can't dispatch */
600Sstevel@tonic-gate #define	TQ_NOALLOC	0x04	/* cannot allocate memory; may fail */
61*11173SJonathan.Adams@Sun.COM #define	TQ_FRONT	0x08	/* Put task at the front of the queue */
620Sstevel@tonic-gate 
630Sstevel@tonic-gate #ifdef _KERNEL
640Sstevel@tonic-gate 
650Sstevel@tonic-gate extern taskq_t *system_taskq;
660Sstevel@tonic-gate 
670Sstevel@tonic-gate extern void	taskq_init(void);
689515SJonathan.Adams@Sun.COM extern void	taskq_mp_init(void);
690Sstevel@tonic-gate 
700Sstevel@tonic-gate extern taskq_t	*taskq_create(const char *, int, pri_t, int, int, uint_t);
710Sstevel@tonic-gate extern taskq_t	*taskq_create_instance(const char *, int, int, pri_t, int,
720Sstevel@tonic-gate     int, uint_t);
73*11173SJonathan.Adams@Sun.COM extern taskq_t	*taskq_create_proc(const char *, int, pri_t, int, int,
74*11173SJonathan.Adams@Sun.COM     struct proc *, uint_t);
75*11173SJonathan.Adams@Sun.COM extern taskq_t	*taskq_create_sysdc(const char *, int, int, int,
76*11173SJonathan.Adams@Sun.COM     struct proc *, uint_t, uint_t);
770Sstevel@tonic-gate extern taskqid_t taskq_dispatch(taskq_t *, task_func_t, void *, uint_t);
780Sstevel@tonic-gate extern void	nulltask(void *);
790Sstevel@tonic-gate extern void	taskq_destroy(taskq_t *);
800Sstevel@tonic-gate extern void	taskq_wait(taskq_t *);
810Sstevel@tonic-gate extern void	taskq_suspend(taskq_t *);
820Sstevel@tonic-gate extern int	taskq_suspended(taskq_t *);
830Sstevel@tonic-gate extern void	taskq_resume(taskq_t *);
840Sstevel@tonic-gate extern int	taskq_member(taskq_t *, kthread_t *);
850Sstevel@tonic-gate 
860Sstevel@tonic-gate #endif	/* _KERNEL */
870Sstevel@tonic-gate 
880Sstevel@tonic-gate #ifdef	__cplusplus
890Sstevel@tonic-gate }
900Sstevel@tonic-gate #endif
910Sstevel@tonic-gate 
920Sstevel@tonic-gate #endif	/* _SYS_TASKQ_H */
93