xref: /onnv-gate/usr/src/uts/common/sys/schedctl.h (revision 4389:81a455c783e3)
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  */
210Sstevel@tonic-gate /*
223792Sakolb  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate /*
270Sstevel@tonic-gate  * The enclosed is a private interface between system libraries and
280Sstevel@tonic-gate  * the kernel.  It should not be used in any other way.  It may be
290Sstevel@tonic-gate  * changed without notice in a minor release of Solaris.
300Sstevel@tonic-gate  */
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #ifndef	_SYS_SCHEDCTL_H
330Sstevel@tonic-gate #define	_SYS_SCHEDCTL_H
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #ifdef	__cplusplus
380Sstevel@tonic-gate extern "C" {
390Sstevel@tonic-gate #endif
400Sstevel@tonic-gate 
410Sstevel@tonic-gate #if !defined(_ASM)
420Sstevel@tonic-gate 
430Sstevel@tonic-gate #include <sys/types.h>
440Sstevel@tonic-gate #include <sys/processor.h>
450Sstevel@tonic-gate #ifdef	_KERNEL
460Sstevel@tonic-gate #include <sys/mutex.h>
470Sstevel@tonic-gate #include <sys/thread.h>
480Sstevel@tonic-gate #include <sys/vnode.h>
490Sstevel@tonic-gate #include <sys/cpuvar.h>
500Sstevel@tonic-gate #include <sys/door.h>
510Sstevel@tonic-gate #endif	/* _KERNEL */
520Sstevel@tonic-gate 
530Sstevel@tonic-gate /*
540Sstevel@tonic-gate  * This "public" portion of the sc_shared data is used by libsched/libc.
550Sstevel@tonic-gate  */
560Sstevel@tonic-gate typedef struct sc_public {
570Sstevel@tonic-gate 	volatile short	sc_nopreempt;
580Sstevel@tonic-gate 	volatile short	sc_yield;
590Sstevel@tonic-gate } sc_public_t;
600Sstevel@tonic-gate 
610Sstevel@tonic-gate /*
620Sstevel@tonic-gate  * The private portion of the sc_shared data is for
630Sstevel@tonic-gate  * use by user-level threading support code in libc.
640Sstevel@tonic-gate  */
650Sstevel@tonic-gate typedef struct sc_shared {
660Sstevel@tonic-gate 	volatile ushort_t sc_state;	/* current LWP state */
670Sstevel@tonic-gate 	volatile char	sc_sigblock;	/* all signals blocked */
680Sstevel@tonic-gate 	volatile char	sc_park;	/* calling lwp_park() */
690Sstevel@tonic-gate 	volatile processorid_t sc_cpu;	/* last CPU on which LWP ran */
700Sstevel@tonic-gate 	int		sc_pad;
710Sstevel@tonic-gate 	sc_public_t	sc_preemptctl;	/* preemption control data */
720Sstevel@tonic-gate } sc_shared_t;
730Sstevel@tonic-gate 
740Sstevel@tonic-gate /*
750Sstevel@tonic-gate  * Possible state settings.  These are same as the kernel thread states
760Sstevel@tonic-gate  * except there is no zombie state.
770Sstevel@tonic-gate  */
780Sstevel@tonic-gate #define	SC_FREE		0x00
790Sstevel@tonic-gate #define	SC_SLEEP	0x01
800Sstevel@tonic-gate #define	SC_RUN		0x02
810Sstevel@tonic-gate #define	SC_ONPROC	0x04
820Sstevel@tonic-gate #define	SC_STOPPED	0x10
833792Sakolb #define	SC_WAIT		0x20
840Sstevel@tonic-gate 
850Sstevel@tonic-gate /* preemption control settings */
860Sstevel@tonic-gate #define	SC_MAX_TICKS	2		/* max time preemption can be blocked */
870Sstevel@tonic-gate 
880Sstevel@tonic-gate #ifdef	_KERNEL
890Sstevel@tonic-gate caddr_t	schedctl(void);
900Sstevel@tonic-gate void	schedctl_init(void);
910Sstevel@tonic-gate void	schedctl_lwp_cleanup(kthread_t *);
920Sstevel@tonic-gate void	schedctl_proc_cleanup(void);
930Sstevel@tonic-gate int	schedctl_get_nopreempt(kthread_t *);
940Sstevel@tonic-gate void	schedctl_set_nopreempt(kthread_t *, short);
950Sstevel@tonic-gate void	schedctl_set_yield(kthread_t *, short);
960Sstevel@tonic-gate int	schedctl_sigblock(kthread_t *);
970Sstevel@tonic-gate void	schedctl_finish_sigblock(kthread_t *);
980Sstevel@tonic-gate int	schedctl_is_park(void);
99*4389Ssl108498 void	schedctl_set_park(void);
1000Sstevel@tonic-gate void	schedctl_unpark(void);
1010Sstevel@tonic-gate #endif	/* _KERNEL */
1020Sstevel@tonic-gate 
1030Sstevel@tonic-gate #endif	/* !defined(_ASM) */
1040Sstevel@tonic-gate 
1050Sstevel@tonic-gate #ifdef	__cplusplus
1060Sstevel@tonic-gate }
1070Sstevel@tonic-gate #endif
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate #endif	/* _SYS_SCHEDCTL_H */
110