xref: /onnv-gate/usr/src/uts/common/sys/schedctl.h (revision 6247:ad4c702ff226)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
53792Sakolb  * Common Development and Distribution License (the "License").
63792Sakolb  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
215891Sraf 
220Sstevel@tonic-gate /*
235891Sraf  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate /*
280Sstevel@tonic-gate  * The enclosed is a private interface between system libraries and
290Sstevel@tonic-gate  * the kernel.  It should not be used in any other way.  It may be
300Sstevel@tonic-gate  * changed without notice in a minor release of Solaris.
310Sstevel@tonic-gate  */
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #ifndef	_SYS_SCHEDCTL_H
340Sstevel@tonic-gate #define	_SYS_SCHEDCTL_H
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
370Sstevel@tonic-gate 
380Sstevel@tonic-gate #ifdef	__cplusplus
390Sstevel@tonic-gate extern "C" {
400Sstevel@tonic-gate #endif
410Sstevel@tonic-gate 
420Sstevel@tonic-gate #if !defined(_ASM)
430Sstevel@tonic-gate 
440Sstevel@tonic-gate #include <sys/types.h>
450Sstevel@tonic-gate #include <sys/processor.h>
460Sstevel@tonic-gate 
470Sstevel@tonic-gate /*
480Sstevel@tonic-gate  * This "public" portion of the sc_shared data is used by libsched/libc.
490Sstevel@tonic-gate  */
500Sstevel@tonic-gate typedef struct sc_public {
510Sstevel@tonic-gate 	volatile short	sc_nopreempt;
520Sstevel@tonic-gate 	volatile short	sc_yield;
530Sstevel@tonic-gate } sc_public_t;
540Sstevel@tonic-gate 
550Sstevel@tonic-gate /*
560Sstevel@tonic-gate  * The private portion of the sc_shared data is for
570Sstevel@tonic-gate  * use by user-level threading support code in libc.
585891Sraf  * Java has a contract to look at sc_state and sc_cpu (PSARC/2005/351).
590Sstevel@tonic-gate  */
600Sstevel@tonic-gate typedef struct sc_shared {
610Sstevel@tonic-gate 	volatile ushort_t sc_state;	/* current LWP state */
620Sstevel@tonic-gate 	volatile char	sc_sigblock;	/* all signals blocked */
635891Sraf 	volatile uchar_t sc_flgs;	/* set only by curthread; see below */
640Sstevel@tonic-gate 	volatile processorid_t sc_cpu;	/* last CPU on which LWP ran */
65*6247Sraf 	volatile char	sc_cid;		/* scheduling class id */
66*6247Sraf 	volatile char	sc_cpri;	/* class priority, -128..127 */
67*6247Sraf 	volatile uchar_t sc_priority;	/* dispatch priority, 0..255 */
68*6247Sraf 	char		sc_pad;
690Sstevel@tonic-gate 	sc_public_t	sc_preemptctl;	/* preemption control data */
700Sstevel@tonic-gate } sc_shared_t;
710Sstevel@tonic-gate 
725891Sraf /* sc_flgs */
735891Sraf #define	SC_PARK_FLG	0x01	/* calling lwp_park() */
745891Sraf #define	SC_CANCEL_FLG	0x02	/* cancel pending and not disabled */
755891Sraf #define	SC_EINTR_FLG	0x04	/* EINTR returned due to SC_CANCEL_FLG */
765891Sraf 
770Sstevel@tonic-gate /*
780Sstevel@tonic-gate  * Possible state settings.  These are same as the kernel thread states
790Sstevel@tonic-gate  * except there is no zombie state.
800Sstevel@tonic-gate  */
810Sstevel@tonic-gate #define	SC_FREE		0x00
820Sstevel@tonic-gate #define	SC_SLEEP	0x01
830Sstevel@tonic-gate #define	SC_RUN		0x02
840Sstevel@tonic-gate #define	SC_ONPROC	0x04
850Sstevel@tonic-gate #define	SC_STOPPED	0x10
863792Sakolb #define	SC_WAIT		0x20
870Sstevel@tonic-gate 
880Sstevel@tonic-gate /* preemption control settings */
890Sstevel@tonic-gate #define	SC_MAX_TICKS	2		/* max time preemption can be blocked */
900Sstevel@tonic-gate 
910Sstevel@tonic-gate #ifdef	_KERNEL
920Sstevel@tonic-gate caddr_t	schedctl(void);
930Sstevel@tonic-gate void	schedctl_init(void);
940Sstevel@tonic-gate void	schedctl_lwp_cleanup(kthread_t *);
950Sstevel@tonic-gate void	schedctl_proc_cleanup(void);
960Sstevel@tonic-gate int	schedctl_get_nopreempt(kthread_t *);
970Sstevel@tonic-gate void	schedctl_set_nopreempt(kthread_t *, short);
980Sstevel@tonic-gate void	schedctl_set_yield(kthread_t *, short);
99*6247Sraf void	schedctl_set_cidpri(kthread_t *);
1000Sstevel@tonic-gate int	schedctl_sigblock(kthread_t *);
1010Sstevel@tonic-gate void	schedctl_finish_sigblock(kthread_t *);
1025891Sraf int	schedctl_cancel_pending(void);
1035891Sraf void	schedctl_cancel_eintr(void);
1040Sstevel@tonic-gate int	schedctl_is_park(void);
1054389Ssl108498 void	schedctl_set_park(void);
1060Sstevel@tonic-gate void	schedctl_unpark(void);
1070Sstevel@tonic-gate #endif	/* _KERNEL */
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate #endif	/* !defined(_ASM) */
1100Sstevel@tonic-gate 
1110Sstevel@tonic-gate #ifdef	__cplusplus
1120Sstevel@tonic-gate }
1130Sstevel@tonic-gate #endif
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate #endif	/* _SYS_SCHEDCTL_H */
116