xref: /illumos-gate/usr/src/uts/common/sys/schedctl.h (revision 03831d35)
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 1997-2003 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  */
66 typedef struct sc_shared {
67 	volatile ushort_t sc_state;	/* current LWP state */
68 	volatile char	sc_sigblock;	/* all signals blocked */
69 	volatile char	sc_park;	/* calling lwp_park() */
70 	volatile processorid_t sc_cpu;	/* last CPU on which LWP ran */
71 	int		sc_pad;
72 	sc_public_t	sc_preemptctl;	/* preemption control data */
73 } sc_shared_t;
74 
75 /*
76  * Possible state settings.  These are same as the kernel thread states
77  * except there is no zombie state.
78  */
79 #define	SC_FREE		0x00
80 #define	SC_SLEEP	0x01
81 #define	SC_RUN		0x02
82 #define	SC_ONPROC	0x04
83 #define	SC_STOPPED	0x10
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