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