xref: /titanic_41/usr/src/uts/common/sys/schedctl.h (revision 4aac33d31b41cc7e3ac6fb66747ff2cae63d08cf)
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 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  * The enclosed is a private interface between system libraries and
28  * the kernel.  It should not be used in any other way.  It may be
29  * changed without notice in a minor release of Solaris.
30  */
31 
32 #ifndef	_SYS_SCHEDCTL_H
33 #define	_SYS_SCHEDCTL_H
34 
35 #pragma ident	"%Z%%M%	%I%	%E% SMI"
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 #if !defined(_ASM)
42 
43 #include <sys/types.h>
44 #include <sys/processor.h>
45 #ifdef	_KERNEL
46 #include <sys/mutex.h>
47 #include <sys/thread.h>
48 #include <sys/vnode.h>
49 #include <sys/cpuvar.h>
50 #include <sys/door.h>
51 #endif	/* _KERNEL */
52 
53 /*
54  * This "public" portion of the sc_shared data is used by libsched/libc.
55  */
56 typedef struct sc_public {
57 	volatile short	sc_nopreempt;
58 	volatile short	sc_yield;
59 } sc_public_t;
60 
61 /*
62  * The private portion of the sc_shared data is for
63  * use by user-level threading support code in libc.
64  */
65 typedef struct sc_shared {
66 	volatile ushort_t sc_state;	/* current LWP state */
67 	volatile char	sc_sigblock;	/* all signals blocked */
68 	volatile char	sc_park;	/* calling lwp_park() */
69 	volatile processorid_t sc_cpu;	/* last CPU on which LWP ran */
70 	int		sc_pad;
71 	sc_public_t	sc_preemptctl;	/* preemption control data */
72 } sc_shared_t;
73 
74 /*
75  * Possible state settings.  These are same as the kernel thread states
76  * except there is no zombie state.
77  */
78 #define	SC_FREE		0x00
79 #define	SC_SLEEP	0x01
80 #define	SC_RUN		0x02
81 #define	SC_ONPROC	0x04
82 #define	SC_STOPPED	0x10
83 #define	SC_WAIT		0x20
84 
85 /* preemption control settings */
86 #define	SC_MAX_TICKS	2		/* max time preemption can be blocked */
87 
88 #ifdef	_KERNEL
89 caddr_t	schedctl(void);
90 void	schedctl_init(void);
91 void	schedctl_lwp_cleanup(kthread_t *);
92 void	schedctl_proc_cleanup(void);
93 int	schedctl_get_nopreempt(kthread_t *);
94 void	schedctl_set_nopreempt(kthread_t *, short);
95 void	schedctl_set_yield(kthread_t *, short);
96 int	schedctl_sigblock(kthread_t *);
97 void	schedctl_finish_sigblock(kthread_t *);
98 int	schedctl_is_park(void);
99 void	schedctl_unpark(void);
100 #endif	/* _KERNEL */
101 
102 #endif	/* !defined(_ASM) */
103 
104 #ifdef	__cplusplus
105 }
106 #endif
107 
108 #endif	/* _SYS_SCHEDCTL_H */
109