17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5c97ad5cdSakolb * Common Development and Distribution License (the "License"). 6c97ad5cdSakolb * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21*a574db85Sraf 227c478bd9Sstevel@tonic-gate /* 23*a574db85Sraf * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate /* 287c478bd9Sstevel@tonic-gate * The enclosed is a private interface between system libraries and 297c478bd9Sstevel@tonic-gate * the kernel. It should not be used in any other way. It may be 307c478bd9Sstevel@tonic-gate * changed without notice in a minor release of Solaris. 317c478bd9Sstevel@tonic-gate */ 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #ifndef _SYS_SCHEDCTL_H 347c478bd9Sstevel@tonic-gate #define _SYS_SCHEDCTL_H 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #ifdef __cplusplus 397c478bd9Sstevel@tonic-gate extern "C" { 407c478bd9Sstevel@tonic-gate #endif 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate #if !defined(_ASM) 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate #include <sys/types.h> 457c478bd9Sstevel@tonic-gate #include <sys/processor.h> 467c478bd9Sstevel@tonic-gate #ifdef _KERNEL 477c478bd9Sstevel@tonic-gate #include <sys/mutex.h> 487c478bd9Sstevel@tonic-gate #include <sys/thread.h> 497c478bd9Sstevel@tonic-gate #include <sys/vnode.h> 507c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h> 517c478bd9Sstevel@tonic-gate #include <sys/door.h> 527c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate /* 557c478bd9Sstevel@tonic-gate * This "public" portion of the sc_shared data is used by libsched/libc. 567c478bd9Sstevel@tonic-gate */ 577c478bd9Sstevel@tonic-gate typedef struct sc_public { 587c478bd9Sstevel@tonic-gate volatile short sc_nopreempt; 597c478bd9Sstevel@tonic-gate volatile short sc_yield; 607c478bd9Sstevel@tonic-gate } sc_public_t; 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate /* 637c478bd9Sstevel@tonic-gate * The private portion of the sc_shared data is for 647c478bd9Sstevel@tonic-gate * use by user-level threading support code in libc. 65*a574db85Sraf * Java has a contract to look at sc_state and sc_cpu (PSARC/2005/351). 667c478bd9Sstevel@tonic-gate */ 677c478bd9Sstevel@tonic-gate typedef struct sc_shared { 687c478bd9Sstevel@tonic-gate volatile ushort_t sc_state; /* current LWP state */ 697c478bd9Sstevel@tonic-gate volatile char sc_sigblock; /* all signals blocked */ 70*a574db85Sraf volatile uchar_t sc_flgs; /* set only by curthread; see below */ 717c478bd9Sstevel@tonic-gate volatile processorid_t sc_cpu; /* last CPU on which LWP ran */ 727c478bd9Sstevel@tonic-gate int sc_pad; 737c478bd9Sstevel@tonic-gate sc_public_t sc_preemptctl; /* preemption control data */ 747c478bd9Sstevel@tonic-gate } sc_shared_t; 757c478bd9Sstevel@tonic-gate 76*a574db85Sraf /* sc_flgs */ 77*a574db85Sraf #define SC_PARK_FLG 0x01 /* calling lwp_park() */ 78*a574db85Sraf #define SC_CANCEL_FLG 0x02 /* cancel pending and not disabled */ 79*a574db85Sraf #define SC_EINTR_FLG 0x04 /* EINTR returned due to SC_CANCEL_FLG */ 80*a574db85Sraf 817c478bd9Sstevel@tonic-gate /* 827c478bd9Sstevel@tonic-gate * Possible state settings. These are same as the kernel thread states 837c478bd9Sstevel@tonic-gate * except there is no zombie state. 847c478bd9Sstevel@tonic-gate */ 857c478bd9Sstevel@tonic-gate #define SC_FREE 0x00 867c478bd9Sstevel@tonic-gate #define SC_SLEEP 0x01 877c478bd9Sstevel@tonic-gate #define SC_RUN 0x02 887c478bd9Sstevel@tonic-gate #define SC_ONPROC 0x04 897c478bd9Sstevel@tonic-gate #define SC_STOPPED 0x10 90c97ad5cdSakolb #define SC_WAIT 0x20 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate /* preemption control settings */ 937c478bd9Sstevel@tonic-gate #define SC_MAX_TICKS 2 /* max time preemption can be blocked */ 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate #ifdef _KERNEL 967c478bd9Sstevel@tonic-gate caddr_t schedctl(void); 977c478bd9Sstevel@tonic-gate void schedctl_init(void); 987c478bd9Sstevel@tonic-gate void schedctl_lwp_cleanup(kthread_t *); 997c478bd9Sstevel@tonic-gate void schedctl_proc_cleanup(void); 1007c478bd9Sstevel@tonic-gate int schedctl_get_nopreempt(kthread_t *); 1017c478bd9Sstevel@tonic-gate void schedctl_set_nopreempt(kthread_t *, short); 1027c478bd9Sstevel@tonic-gate void schedctl_set_yield(kthread_t *, short); 1037c478bd9Sstevel@tonic-gate int schedctl_sigblock(kthread_t *); 1047c478bd9Sstevel@tonic-gate void schedctl_finish_sigblock(kthread_t *); 105*a574db85Sraf int schedctl_cancel_pending(void); 106*a574db85Sraf void schedctl_cancel_eintr(void); 1077c478bd9Sstevel@tonic-gate int schedctl_is_park(void); 10847eb4d1eSsl108498 void schedctl_set_park(void); 1097c478bd9Sstevel@tonic-gate void schedctl_unpark(void); 1107c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate #endif /* !defined(_ASM) */ 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1157c478bd9Sstevel@tonic-gate } 1167c478bd9Sstevel@tonic-gate #endif 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate #endif /* _SYS_SCHEDCTL_H */ 119