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