Merge commit '7e3488dc6cdcb0c04e1ce167a1a3bfef83b5f2e0'
[unleashed.git] / include / sys / schedctl.h
blob010b343669147b55d05104332382080565cb6ad3
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
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.
33 #ifndef _SYS_SCHEDCTL_H
34 #define _SYS_SCHEDCTL_H
36 #pragma ident "%Z%%M% %I% %E% SMI"
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
42 #if !defined(_ASM)
44 #include <sys/types.h>
45 #include <sys/processor.h>
48 * This "public" portion of the sc_shared data is used by libsched/libc.
50 typedef struct sc_public {
51 volatile short sc_nopreempt;
52 volatile short sc_yield;
53 } sc_public_t;
56 * The private portion of the sc_shared data is for
57 * use by user-level threading support code in libc.
58 * Java has a contract to look at sc_state and sc_cpu (PSARC/2005/351).
60 typedef struct sc_shared {
61 volatile ushort_t sc_state; /* current LWP state */
62 volatile char sc_sigblock; /* all signals blocked */
63 volatile uchar_t sc_flgs; /* set only by curthread; see below */
64 volatile processorid_t sc_cpu; /* last CPU on which LWP ran */
65 volatile char sc_cid; /* scheduling class id */
66 volatile char sc_cpri; /* class priority, -128..127 */
67 volatile uchar_t sc_priority; /* dispatch priority, 0..255 */
68 char sc_pad;
69 sc_public_t sc_preemptctl; /* preemption control data */
70 } sc_shared_t;
72 /* sc_flgs */
73 #define SC_PARK_FLG 0x01 /* calling lwp_park() */
74 #define SC_CANCEL_FLG 0x02 /* cancel pending and not disabled */
75 #define SC_EINTR_FLG 0x04 /* EINTR returned due to SC_CANCEL_FLG */
78 * Possible state settings. These are same as the kernel thread states
79 * except there is no zombie state.
81 #define SC_FREE 0x00
82 #define SC_SLEEP 0x01
83 #define SC_RUN 0x02
84 #define SC_ONPROC 0x04
85 #define SC_STOPPED 0x10
86 #define SC_WAIT 0x20
88 /* preemption control settings */
89 #define SC_MAX_TICKS 2 /* max time preemption can be blocked */
91 #ifdef _KERNEL
92 caddr_t schedctl(void);
93 void schedctl_init(void);
94 void schedctl_lwp_cleanup(kthread_t *);
95 void schedctl_proc_cleanup(void);
96 int schedctl_get_nopreempt(kthread_t *);
97 void schedctl_set_nopreempt(kthread_t *, short);
98 void schedctl_set_yield(kthread_t *, short);
99 void schedctl_set_cidpri(kthread_t *);
100 int schedctl_sigblock(kthread_t *);
101 void schedctl_finish_sigblock(kthread_t *);
102 int schedctl_cancel_pending(void);
103 void schedctl_cancel_eintr(void);
104 int schedctl_is_park(void);
105 void schedctl_set_park(void);
106 void schedctl_unpark(void);
107 #endif /* _KERNEL */
109 #endif /* !defined(_ASM) */
111 #ifdef __cplusplus
113 #endif
115 #endif /* _SYS_SCHEDCTL_H */