The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/kern/timer.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /* 
    2  * Mach Operating System
    3  * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
    4  * All Rights Reserved.
    5  * 
    6  * Permission to use, copy, modify and distribute this software and its
    7  * documentation is hereby granted, provided that both the copyright
    8  * notice and this permission notice appear in all copies of the
    9  * software, derivative works or modified versions, and any portions
   10  * thereof, and that both notices appear in supporting documentation.
   11  * 
   12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
   14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   15  * 
   16  * Carnegie Mellon requests users of this software to return to
   17  * 
   18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   19  *  School of Computer Science
   20  *  Carnegie Mellon University
   21  *  Pittsburgh PA 15213-3890
   22  * 
   23  * any improvements or extensions that they make and grant Carnegie Mellon
   24  * the rights to redistribute these changes.
   25  */
   26 /*
   27  * HISTORY
   28  * $Log:        timer.h,v $
   29  * Revision 2.5  92/05/21  17:17:07  jfriedl
   30  *      Appended 'U' to constants that would otherwise be signed.
   31  *      [92/05/16            jfriedl]
   32  * 
   33  * Revision 2.4  91/05/14  16:50:00  mrt
   34  *      Correcting copyright
   35  * 
   36  * Revision 2.3  91/02/05  17:31:10  mrt
   37  *      Changed to new Mach copyright
   38  *      [91/02/01  16:21:08  mrt]
   39  * 
   40  * Revision 2.2  90/08/07  18:00:13  rpd
   41  *      Picked up new timer representation.
   42  * 
   43  * Revision 2.1  89/08/03  15:57:34  rwd
   44  * Created.
   45  * 
   46  * 27-Oct-88  David Black (dlb) at Carnegie-Mellon University
   47  *      Added TIMER_LOW_FULL mask to check for possible overflow of
   48  *      low_bits field.  Removed TIMER_SERVICE flag.
   49  *
   50  * Revision 2.3  88/08/24  02:49:17  mwyoung
   51  *      Adjusted include file references.
   52  *      [88/08/17  02:25:43  mwyoung]
   53  * 
   54  *
   55  *  7-Apr-88  David Black (dlb) at Carnegie-Mellon University
   56  *      Added interface definitions and null routines for STAT_TIME.
   57  *
   58  * 19-Feb-88  David Black (dlb) at Carnegie-Mellon University
   59  *      Renamed fields, added timer_save structure.
   60  *
   61  * 31-May-87  Avadis Tevanian (avie) at Carnegie-Mellon University
   62  *      machine/machtimer.h -> machine/timer.h
   63  *
   64  * 23-Feb-87  David L. Black (dlb) at Carnegie-Mellon University
   65  *      Created.
   66  */ 
   67 
   68 #ifndef _KERN_TIMER_H_
   69 #define _KERN_TIMER_H_
   70 
   71 #include <cpus.h>
   72 #include <stat_time.h>
   73 
   74 #include <kern/macro_help.h>
   75 
   76 #if     STAT_TIME
   77 /*
   78  *      Statistical timer definitions - use microseconds in timer, seconds
   79  *      in high unit field.  No adjustment needed to convert to time_value_t
   80  *      as a result.  Service timers once an hour.
   81  */
   82 
   83 #define TIMER_RATE      1000000
   84 #define TIMER_HIGH_UNIT TIMER_RATE
   85 #undef  TIMER_ADJUST
   86 
   87 #else   STAT_TIME
   88 /*
   89  *      Machine dependent definitions based on hardware support.
   90  */
   91 
   92 #include <machine/timer.h>
   93 
   94 #endif  STAT_TIME
   95 
   96 /*
   97  *      Definitions for accurate timers.  high_bits_check is a copy of
   98  *      high_bits that allows reader to verify that values read are ok.
   99  */
  100 
  101 struct timer {
  102         unsigned        low_bits;
  103         unsigned        high_bits;
  104         unsigned        high_bits_check;
  105         unsigned        tstamp;
  106 };
  107 
  108 typedef struct timer            timer_data_t;
  109 typedef struct timer            *timer_t;
  110 
  111 /*
  112  *      Mask to check if low_bits is in danger of overflowing
  113  */
  114 
  115 #define TIMER_LOW_FULL  0x80000000U
  116 
  117 /*
  118  *      Kernel timers and current timer array.  [Exported]
  119  */
  120 
  121 extern timer_t          current_timer[NCPUS];
  122 extern timer_data_t     kernel_timer[NCPUS];
  123 
  124 /*
  125  *      save structure for timer readings.  This is used to save timer
  126  *      readings for elapsed time computations.
  127  */
  128 
  129 struct timer_save {
  130         unsigned        low;
  131         unsigned        high;
  132 };
  133 
  134 typedef struct timer_save       timer_save_data_t, *timer_save_t;
  135 
  136 /*
  137  *      Exported kernel interface to timers
  138  */
  139 
  140 #if     STAT_TIME
  141 #define start_timer(timer)
  142 #define timer_switch(timer)
  143 #else   STAT_TIME
  144 extern void     start_timer();
  145 extern void     timer_switch();
  146 #endif  STAT_TIME
  147 
  148 extern void             timer_read();
  149 extern void             thread_read_times();
  150 extern unsigned         timer_delta();
  151 
  152 #if     STAT_TIME
  153 /*
  154  *      Macro to bump timer values.
  155  */     
  156 #define timer_bump(timer, usec)                                 \
  157 MACRO_BEGIN                                                     \
  158         (timer)->low_bits += usec;                              \
  159         if ((timer)->low_bits & TIMER_LOW_FULL) {               \
  160                 timer_normalize(timer);                         \
  161         }                                                       \
  162 MACRO_END
  163 
  164 #else   STAT_TIME
  165 /*
  166  *      Exported hardware interface to timers
  167  */
  168 extern void     time_trap_uentry();
  169 extern void     time_trap_uexit();
  170 extern timer_t  time_int_entry();
  171 extern void     time_int_exit();
  172 #endif  STAT_TIME
  173 
  174 /*
  175  *      TIMER_DELTA finds the difference between a timer and a saved value,
  176  *      and updates the saved value.  Look at high_bits check field after
  177  *      reading low because that's the first written by a normalize
  178  *      operation; this isn't necessary for current usage because
  179  *      this macro is only used when the timer can't be normalized:
  180  *      thread is not running, or running thread calls it on itself at
  181  *      splsched().
  182  */
  183 
  184 #define TIMER_DELTA(timer, save, result)                        \
  185 MACRO_BEGIN                                                     \
  186         register unsigned       temp;                           \
  187                                                                 \
  188         temp = (timer).low_bits;                                \
  189         if ((save).high != (timer).high_bits_check) {           \
  190                 result += timer_delta(&(timer), &(save));       \
  191         }                                                       \
  192         else {                                                  \
  193                 result += temp - (save).low;                    \
  194                 (save).low = temp;                              \
  195         }                                                       \
  196 MACRO_END
  197 
  198 #endif  _KERN_TIMER_H_

Cache object: c53005e14acb60927d8bd41bab9d498d


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.