xref: /netbsd/sys/sys/kthread.h (revision 6550d01e)
1 /*	$NetBSD: kthread.h,v 1.9 2010/05/11 22:26:00 haad Exp $	*/
2 
3 /*-
4  * Copyright (c) 1998, 2007, 2009 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9  * NASA Ames Research Center, and by Andrew Doran.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef _SYS_KTHREAD_H_
34 #define	_SYS_KTHREAD_H_
35 
36 /*
37  * Kernel thread handling.
38  */
39 
40 #ifdef _KERNEL
41 #include <sys/proc.h>
42 
43 #define	KTHREAD_IDLE	0x01	/* do not set runnable */
44 #define	KTHREAD_MPSAFE	0x02	/* does not need kernel_lock */
45 #define	KTHREAD_INTR	0x04	/* interrupt handler */
46 #define	KTHREAD_TS	0x08	/* timeshared */
47 #define	KTHREAD_JOINABLE	0x10	/* joinable thread */
48 
49 int	kthread_create(pri_t, int, struct cpu_info *,
50 		       void (*)(void *), void *,
51 		       lwp_t **, const char *, ...)
52 	    __attribute__((__format__(__printf__,7,8)));
53 void	kthread_exit(int) __dead;
54 void	kthread_destroy(lwp_t *);
55 int	kthread_join(lwp_t *);
56 #endif /* _KERNEL */
57 
58 #endif /* _SYS_KTHREAD_H_ */
59