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 */ 21a574db85Sraf 227c478bd9Sstevel@tonic-gate /* 23a574db85Sraf * 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 477c478bd9Sstevel@tonic-gate /* 487c478bd9Sstevel@tonic-gate * This "public" portion of the sc_shared data is used by libsched/libc. 497c478bd9Sstevel@tonic-gate */ 507c478bd9Sstevel@tonic-gate typedef struct sc_public { 517c478bd9Sstevel@tonic-gate volatile short sc_nopreempt; 527c478bd9Sstevel@tonic-gate volatile short sc_yield; 537c478bd9Sstevel@tonic-gate } sc_public_t; 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate /* 567c478bd9Sstevel@tonic-gate * The private portion of the sc_shared data is for 577c478bd9Sstevel@tonic-gate * use by user-level threading support code in libc. 58a574db85Sraf * Java has a contract to look at sc_state and sc_cpu (PSARC/2005/351). 597c478bd9Sstevel@tonic-gate */ 607c478bd9Sstevel@tonic-gate typedef struct sc_shared { 617c478bd9Sstevel@tonic-gate volatile ushort_t sc_state; /* current LWP state */ 627c478bd9Sstevel@tonic-gate volatile char sc_sigblock; /* all signals blocked */ 63a574db85Sraf volatile uchar_t sc_flgs; /* set only by curthread; see below */ 647c478bd9Sstevel@tonic-gate volatile processorid_t sc_cpu; /* last CPU on which LWP ran */ 65*d4204c85Sraf volatile char sc_cid; /* scheduling class id */ 66*d4204c85Sraf volatile char sc_cpri; /* class priority, -128..127 */ 67*d4204c85Sraf volatile uchar_t sc_priority; /* dispatch priority, 0..255 */ 68*d4204c85Sraf char sc_pad; 697c478bd9Sstevel@tonic-gate sc_public_t sc_preemptctl; /* preemption control data */ 707c478bd9Sstevel@tonic-gate } sc_shared_t; 717c478bd9Sstevel@tonic-gate 72a574db85Sraf /* sc_flgs */ 73a574db85Sraf #define SC_PARK_FLG 0x01 /* calling lwp_park() */ 74a574db85Sraf #define SC_CANCEL_FLG 0x02 /* cancel pending and not disabled */ 75a574db85Sraf #define SC_EINTR_FLG 0x04 /* EINTR returned due to SC_CANCEL_FLG */ 76a574db85Sraf 777c478bd9Sstevel@tonic-gate /* 787c478bd9Sstevel@tonic-gate * Possible state settings. These are same as the kernel thread states 797c478bd9Sstevel@tonic-gate * except there is no zombie state. 807c478bd9Sstevel@tonic-gate */ 817c478bd9Sstevel@tonic-gate #define SC_FREE 0x00 827c478bd9Sstevel@tonic-gate #define SC_SLEEP 0x01 837c478bd9Sstevel@tonic-gate #define SC_RUN 0x02 847c478bd9Sstevel@tonic-gate #define SC_ONPROC 0x04 857c478bd9Sstevel@tonic-gate #define SC_STOPPED 0x10 86c97ad5cdSakolb #define SC_WAIT 0x20 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate /* preemption control settings */ 897c478bd9Sstevel@tonic-gate #define SC_MAX_TICKS 2 /* max time preemption can be blocked */ 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate #ifdef _KERNEL 927c478bd9Sstevel@tonic-gate caddr_t schedctl(void); 937c478bd9Sstevel@tonic-gate void schedctl_init(void); 947c478bd9Sstevel@tonic-gate void schedctl_lwp_cleanup(kthread_t *); 957c478bd9Sstevel@tonic-gate void schedctl_proc_cleanup(void); 967c478bd9Sstevel@tonic-gate int schedctl_get_nopreempt(kthread_t *); 977c478bd9Sstevel@tonic-gate void schedctl_set_nopreempt(kthread_t *, short); 987c478bd9Sstevel@tonic-gate void schedctl_set_yield(kthread_t *, short); 99*d4204c85Sraf void schedctl_set_cidpri(kthread_t *); 1007c478bd9Sstevel@tonic-gate int schedctl_sigblock(kthread_t *); 1017c478bd9Sstevel@tonic-gate void schedctl_finish_sigblock(kthread_t *); 102a574db85Sraf int schedctl_cancel_pending(void); 103a574db85Sraf void schedctl_cancel_eintr(void); 1047c478bd9Sstevel@tonic-gate int schedctl_is_park(void); 10547eb4d1eSsl108498 void schedctl_set_park(void); 1067c478bd9Sstevel@tonic-gate void schedctl_unpark(void); 1077c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate #endif /* !defined(_ASM) */ 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1127c478bd9Sstevel@tonic-gate } 1137c478bd9Sstevel@tonic-gate #endif 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate #endif /* _SYS_SCHEDCTL_H */ 116