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 #ifdef __cplusplus 377c478bd9Sstevel@tonic-gate extern "C" { 387c478bd9Sstevel@tonic-gate #endif 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #if !defined(_ASM) 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate #include <sys/types.h> 437c478bd9Sstevel@tonic-gate #include <sys/processor.h> 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate /* 467c478bd9Sstevel@tonic-gate * This "public" portion of the sc_shared data is used by libsched/libc. 477c478bd9Sstevel@tonic-gate */ 487c478bd9Sstevel@tonic-gate typedef struct sc_public { 497c478bd9Sstevel@tonic-gate volatile short sc_nopreempt; 507c478bd9Sstevel@tonic-gate volatile short sc_yield; 517c478bd9Sstevel@tonic-gate } sc_public_t; 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate /* 547c478bd9Sstevel@tonic-gate * The private portion of the sc_shared data is for 557c478bd9Sstevel@tonic-gate * use by user-level threading support code in libc. 56a574db85Sraf * Java has a contract to look at sc_state and sc_cpu (PSARC/2005/351). 577c478bd9Sstevel@tonic-gate */ 587c478bd9Sstevel@tonic-gate typedef struct sc_shared { 597c478bd9Sstevel@tonic-gate volatile ushort_t sc_state; /* current LWP state */ 607c478bd9Sstevel@tonic-gate volatile char sc_sigblock; /* all signals blocked */ 61a574db85Sraf volatile uchar_t sc_flgs; /* set only by curthread; see below */ 627c478bd9Sstevel@tonic-gate volatile processorid_t sc_cpu; /* last CPU on which LWP ran */ 63*d4204c85Sraf volatile char sc_cid; /* scheduling class id */ 64*d4204c85Sraf volatile char sc_cpri; /* class priority, -128..127 */ 65*d4204c85Sraf volatile uchar_t sc_priority; /* dispatch priority, 0..255 */ 66*d4204c85Sraf char sc_pad; 677c478bd9Sstevel@tonic-gate sc_public_t sc_preemptctl; /* preemption control data */ 687c478bd9Sstevel@tonic-gate } sc_shared_t; 697c478bd9Sstevel@tonic-gate 70a574db85Sraf /* sc_flgs */ 71a574db85Sraf #define SC_PARK_FLG 0x01 /* calling lwp_park() */ 72a574db85Sraf #define SC_CANCEL_FLG 0x02 /* cancel pending and not disabled */ 73a574db85Sraf #define SC_EINTR_FLG 0x04 /* EINTR returned due to SC_CANCEL_FLG */ 74a574db85Sraf 757c478bd9Sstevel@tonic-gate /* 767c478bd9Sstevel@tonic-gate * Possible state settings. These are same as the kernel thread states 777c478bd9Sstevel@tonic-gate * except there is no zombie state. 787c478bd9Sstevel@tonic-gate */ 797c478bd9Sstevel@tonic-gate #define SC_FREE 0x00 807c478bd9Sstevel@tonic-gate #define SC_SLEEP 0x01 817c478bd9Sstevel@tonic-gate #define SC_RUN 0x02 827c478bd9Sstevel@tonic-gate #define SC_ONPROC 0x04 837c478bd9Sstevel@tonic-gate #define SC_STOPPED 0x10 84c97ad5cdSakolb #define SC_WAIT 0x20 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate /* preemption control settings */ 877c478bd9Sstevel@tonic-gate #define SC_MAX_TICKS 2 /* max time preemption can be blocked */ 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate #ifdef _KERNEL 907c478bd9Sstevel@tonic-gate caddr_t schedctl(void); 917c478bd9Sstevel@tonic-gate void schedctl_init(void); 927c478bd9Sstevel@tonic-gate void schedctl_lwp_cleanup(kthread_t *); 937c478bd9Sstevel@tonic-gate void schedctl_proc_cleanup(void); 947c478bd9Sstevel@tonic-gate int schedctl_get_nopreempt(kthread_t *); 957c478bd9Sstevel@tonic-gate void schedctl_set_nopreempt(kthread_t *, short); 967c478bd9Sstevel@tonic-gate void schedctl_set_yield(kthread_t *, short); 97*d4204c85Sraf void schedctl_set_cidpri(kthread_t *); 987c478bd9Sstevel@tonic-gate int schedctl_sigblock(kthread_t *); 997c478bd9Sstevel@tonic-gate void schedctl_finish_sigblock(kthread_t *); 100a574db85Sraf int schedctl_cancel_pending(void); 101a574db85Sraf void schedctl_cancel_eintr(void); 1027c478bd9Sstevel@tonic-gate int schedctl_is_park(void); 10347eb4d1eSsl void schedctl_set_park(void); 1047c478bd9Sstevel@tonic-gate void schedctl_unpark(void); 1057c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate #endif /* !defined(_ASM) */ 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1107c478bd9Sstevel@tonic-gate } 1117c478bd9Sstevel@tonic-gate #endif 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate #endif /* _SYS_SCHEDCTL_H */ 114