1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright (c) 2001 by Sun Microsystems, Inc. 24*0Sstevel@tonic-gate * All rights reserved. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _SYS_FX_H 28*0Sstevel@tonic-gate #define _SYS_FX_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #include <sys/types.h> 33*0Sstevel@tonic-gate #include <sys/thread.h> 34*0Sstevel@tonic-gate #include <sys/ddi.h> 35*0Sstevel@tonic-gate #include <sys/sunddi.h> 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gate #ifdef __cplusplus 38*0Sstevel@tonic-gate extern "C" { 39*0Sstevel@tonic-gate #endif 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gate /* 42*0Sstevel@tonic-gate * Fixed-priority dispatcher parameter table entry 43*0Sstevel@tonic-gate */ 44*0Sstevel@tonic-gate typedef struct fxdpent { 45*0Sstevel@tonic-gate pri_t fx_globpri; /* global (class independent) priority */ 46*0Sstevel@tonic-gate int fx_quantum; /* time quantum given to procs at this level */ 47*0Sstevel@tonic-gate } fxdpent_t; 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gate #ifdef _KERNEL 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate typedef uintptr_t fx_cookie_t; /* handle for callback supplied storage */ 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate /* 54*0Sstevel@tonic-gate * callbacks supplied by custom scheduler. In general, a change to quantum 55*0Sstevel@tonic-gate * and/or priority when returning from a callback has immediate effect. 56*0Sstevel@tonic-gate * 57*0Sstevel@tonic-gate * fx_exit - called when a thread exits. This also needs to free any storage 58*0Sstevel@tonic-gate * for the fx_cookie_t. 59*0Sstevel@tonic-gate * 60*0Sstevel@tonic-gate * fx_callb_tick - called at every clock tick attributed to this thread 61*0Sstevel@tonic-gate * 62*0Sstevel@tonic-gate * fx_callb_preempt - called when a thread is being preempted or yielding 63*0Sstevel@tonic-gate * 64*0Sstevel@tonic-gate * fx_callb_stop/fx_callb_sleep - called when a thread stops running 65*0Sstevel@tonic-gate * 66*0Sstevel@tonic-gate * fx_callb_wakeup - called when a thread is again runnable 67*0Sstevel@tonic-gate */ 68*0Sstevel@tonic-gate typedef struct fx_callbacks { 69*0Sstevel@tonic-gate int fx_callb_version; 70*0Sstevel@tonic-gate void (*fx_callb_exit)(fx_cookie_t); 71*0Sstevel@tonic-gate void (*fx_callb_tick)(fx_cookie_t, clock_t *, pri_t *); 72*0Sstevel@tonic-gate void (*fx_callb_preempt)(fx_cookie_t, clock_t *, pri_t *); 73*0Sstevel@tonic-gate void (*fx_callb_stop)(fx_cookie_t); 74*0Sstevel@tonic-gate void (*fx_callb_sleep)(fx_cookie_t); 75*0Sstevel@tonic-gate void (*fx_callb_wakeup)(fx_cookie_t, clock_t *, pri_t *); 76*0Sstevel@tonic-gate 77*0Sstevel@tonic-gate } fx_callbacks_t; 78*0Sstevel@tonic-gate 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gate #define FX_CALLB_VERSION_1 1 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate #define FX_CALLB_REV FX_CALLB_VERSION_1 83*0Sstevel@tonic-gate 84*0Sstevel@tonic-gate #define FX_CB_VERSION(cb) cb->fx_callb_version 85*0Sstevel@tonic-gate 86*0Sstevel@tonic-gate #define FX_CB_EXIT(cb, c) cb->fx_callb_exit(c) 87*0Sstevel@tonic-gate 88*0Sstevel@tonic-gate #define FX_CB_TICK(cb, c, q, p) cb->fx_callb_tick(c, q, p) 89*0Sstevel@tonic-gate 90*0Sstevel@tonic-gate #define FX_CB_PREEMPT(cb, c, q, p) cb->fx_callb_preempt(c, q, p) 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gate #define FX_CB_STOP(cb, c) cb->fx_callb_stop(c) 93*0Sstevel@tonic-gate 94*0Sstevel@tonic-gate #define FX_CB_SLEEP(cb, c) cb->fx_callb_sleep(c) 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gate #define FX_CB_WAKEUP(cb, c, q, p) cb->fx_callb_wakeup(c, q, p) 97*0Sstevel@tonic-gate 98*0Sstevel@tonic-gate /* priority setting */ 99*0Sstevel@tonic-gate #define FX_CB_NOCHANGE -32768 100*0Sstevel@tonic-gate 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gate /* 103*0Sstevel@tonic-gate * Fixed-priority class specific thread structure 104*0Sstevel@tonic-gate */ 105*0Sstevel@tonic-gate typedef struct fxproc { 106*0Sstevel@tonic-gate int fx_pquantum; /* time quantum given to this proc */ 107*0Sstevel@tonic-gate int fx_timeleft; /* time remaining in procs quantum */ 108*0Sstevel@tonic-gate 109*0Sstevel@tonic-gate pri_t fx_pri; /* relative priority within fx class */ 110*0Sstevel@tonic-gate /* same as user priority */ 111*0Sstevel@tonic-gate 112*0Sstevel@tonic-gate pri_t fx_uprilim; /* user priority limit */ 113*0Sstevel@tonic-gate 114*0Sstevel@tonic-gate char fx_nice; /* nice value for compatibility */ 115*0Sstevel@tonic-gate uchar_t fx_flags; /* flags defined below */ 116*0Sstevel@tonic-gate kthread_t *fx_tp; /* pointer to thread */ 117*0Sstevel@tonic-gate struct fxproc *fx_next; /* pointer to next fxproc */ 118*0Sstevel@tonic-gate 119*0Sstevel@tonic-gate struct fxproc *fx_prev; /* pointer to previous fxproc */ 120*0Sstevel@tonic-gate 121*0Sstevel@tonic-gate /* the following are used only when we have callbacks registered */ 122*0Sstevel@tonic-gate kt_did_t fx_ktid; 123*0Sstevel@tonic-gate struct fxproc *fx_cb_next; /* pointer to next fxproc that */ 124*0Sstevel@tonic-gate /* has a callback */ 125*0Sstevel@tonic-gate 126*0Sstevel@tonic-gate struct fxproc *fx_cb_prev; /* pointer to previous fxproc that */ 127*0Sstevel@tonic-gate /* has a callback */ 128*0Sstevel@tonic-gate fx_cookie_t fx_cookie; /* cookie with which callback */ 129*0Sstevel@tonic-gate /* was registered */ 130*0Sstevel@tonic-gate fx_callbacks_t *fx_callback; /* pointer to callback structure */ 131*0Sstevel@tonic-gate } fxproc_t; 132*0Sstevel@tonic-gate 133*0Sstevel@tonic-gate 134*0Sstevel@tonic-gate #define FX_CALLB(fxpp) fxpp->fx_callback 135*0Sstevel@tonic-gate 136*0Sstevel@tonic-gate 137*0Sstevel@tonic-gate /* flags */ 138*0Sstevel@tonic-gate #define FXBACKQ 0x02 /* thread goes to back of disp q when preempted */ 139*0Sstevel@tonic-gate 140*0Sstevel@tonic-gate /* 141*0Sstevel@tonic-gate * Kernel version of fixed-priority class specific parameter structure 142*0Sstevel@tonic-gate */ 143*0Sstevel@tonic-gate typedef struct fxkparms { 144*0Sstevel@tonic-gate pri_t fx_upri; 145*0Sstevel@tonic-gate pri_t fx_uprilim; 146*0Sstevel@tonic-gate int fx_tqntm; 147*0Sstevel@tonic-gate uint_t fx_cflags; 148*0Sstevel@tonic-gate } fxkparms_t; 149*0Sstevel@tonic-gate 150*0Sstevel@tonic-gate 151*0Sstevel@tonic-gate 152*0Sstevel@tonic-gate /* 153*0Sstevel@tonic-gate * Interface for partner private code. This is not a public interface. 154*0Sstevel@tonic-gate */ 155*0Sstevel@tonic-gate extern int fx_register_callbacks(fx_callbacks_t *, fx_cookie_t, pri_t, clock_t); 156*0Sstevel@tonic-gate extern int fx_unregister_callbacks(); 157*0Sstevel@tonic-gate extern int fx_modify_priority(kt_did_t, clock_t, pri_t); 158*0Sstevel@tonic-gate extern void *fx_get_mutex_cookie(); 159*0Sstevel@tonic-gate extern pri_t fx_get_maxpri(); 160*0Sstevel@tonic-gate 161*0Sstevel@tonic-gate #endif /* _KERNEL */ 162*0Sstevel@tonic-gate 163*0Sstevel@tonic-gate #ifdef __cplusplus 164*0Sstevel@tonic-gate } 165*0Sstevel@tonic-gate #endif 166*0Sstevel@tonic-gate 167*0Sstevel@tonic-gate #endif /* _SYS_FX_H */ 168