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 */ 217c478bd9Sstevel@tonic-gate /* 22c97ad5cdSakolb * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* 277c478bd9Sstevel@tonic-gate * The enclosed is a private interface between system libraries and 287c478bd9Sstevel@tonic-gate * the kernel. It should not be used in any other way. It may be 297c478bd9Sstevel@tonic-gate * changed without notice in a minor release of Solaris. 307c478bd9Sstevel@tonic-gate */ 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #ifndef _SYS_SCHEDCTL_H 337c478bd9Sstevel@tonic-gate #define _SYS_SCHEDCTL_H 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #ifdef __cplusplus 387c478bd9Sstevel@tonic-gate extern "C" { 397c478bd9Sstevel@tonic-gate #endif 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate #if !defined(_ASM) 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #include <sys/types.h> 447c478bd9Sstevel@tonic-gate #include <sys/processor.h> 457c478bd9Sstevel@tonic-gate #ifdef _KERNEL 467c478bd9Sstevel@tonic-gate #include <sys/mutex.h> 477c478bd9Sstevel@tonic-gate #include <sys/thread.h> 487c478bd9Sstevel@tonic-gate #include <sys/vnode.h> 497c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h> 507c478bd9Sstevel@tonic-gate #include <sys/door.h> 517c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate /* 547c478bd9Sstevel@tonic-gate * This "public" portion of the sc_shared data is used by libsched/libc. 557c478bd9Sstevel@tonic-gate */ 567c478bd9Sstevel@tonic-gate typedef struct sc_public { 577c478bd9Sstevel@tonic-gate volatile short sc_nopreempt; 587c478bd9Sstevel@tonic-gate volatile short sc_yield; 597c478bd9Sstevel@tonic-gate } sc_public_t; 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate /* 627c478bd9Sstevel@tonic-gate * The private portion of the sc_shared data is for 637c478bd9Sstevel@tonic-gate * use by user-level threading support code in libc. 647c478bd9Sstevel@tonic-gate */ 657c478bd9Sstevel@tonic-gate typedef struct sc_shared { 667c478bd9Sstevel@tonic-gate volatile ushort_t sc_state; /* current LWP state */ 677c478bd9Sstevel@tonic-gate volatile char sc_sigblock; /* all signals blocked */ 687c478bd9Sstevel@tonic-gate volatile char sc_park; /* calling lwp_park() */ 697c478bd9Sstevel@tonic-gate volatile processorid_t sc_cpu; /* last CPU on which LWP ran */ 707c478bd9Sstevel@tonic-gate int sc_pad; 717c478bd9Sstevel@tonic-gate sc_public_t sc_preemptctl; /* preemption control data */ 727c478bd9Sstevel@tonic-gate } sc_shared_t; 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate /* 757c478bd9Sstevel@tonic-gate * Possible state settings. These are same as the kernel thread states 767c478bd9Sstevel@tonic-gate * except there is no zombie state. 777c478bd9Sstevel@tonic-gate */ 787c478bd9Sstevel@tonic-gate #define SC_FREE 0x00 797c478bd9Sstevel@tonic-gate #define SC_SLEEP 0x01 807c478bd9Sstevel@tonic-gate #define SC_RUN 0x02 817c478bd9Sstevel@tonic-gate #define SC_ONPROC 0x04 827c478bd9Sstevel@tonic-gate #define SC_STOPPED 0x10 83c97ad5cdSakolb #define SC_WAIT 0x20 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate /* preemption control settings */ 867c478bd9Sstevel@tonic-gate #define SC_MAX_TICKS 2 /* max time preemption can be blocked */ 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate #ifdef _KERNEL 897c478bd9Sstevel@tonic-gate caddr_t schedctl(void); 907c478bd9Sstevel@tonic-gate void schedctl_init(void); 917c478bd9Sstevel@tonic-gate void schedctl_lwp_cleanup(kthread_t *); 927c478bd9Sstevel@tonic-gate void schedctl_proc_cleanup(void); 937c478bd9Sstevel@tonic-gate int schedctl_get_nopreempt(kthread_t *); 947c478bd9Sstevel@tonic-gate void schedctl_set_nopreempt(kthread_t *, short); 957c478bd9Sstevel@tonic-gate void schedctl_set_yield(kthread_t *, short); 967c478bd9Sstevel@tonic-gate int schedctl_sigblock(kthread_t *); 977c478bd9Sstevel@tonic-gate void schedctl_finish_sigblock(kthread_t *); 987c478bd9Sstevel@tonic-gate int schedctl_is_park(void); 99*47eb4d1eSsl108498 void schedctl_set_park(void); 1007c478bd9Sstevel@tonic-gate void schedctl_unpark(void); 1017c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate #endif /* !defined(_ASM) */ 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1067c478bd9Sstevel@tonic-gate } 1077c478bd9Sstevel@tonic-gate #endif 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate #endif /* _SYS_SCHEDCTL_H */ 110