--- Gnu-Mach/kern/timer.h 2020/09/02 04:36:57 1.1 +++ Gnu-Mach/kern/timer.h 2020/09/02 04:49:53 1.1.1.5 @@ -1,25 +1,25 @@ -/* +/* * Mach Operating System * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University * All Rights Reserved. - * + * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. - * + * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * + * * Carnegie Mellon requests users of this software to return to - * + * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 - * + * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ @@ -27,10 +27,7 @@ #ifndef _KERN_TIMER_H_ #define _KERN_TIMER_H_ -#include -#include - -#include +#include #if STAT_TIME /* @@ -39,18 +36,45 @@ * as a result. Service timers once an hour. */ +/* + * TIMER_MAX is needed if a 32-bit rollover timer needs to be adjusted for + * maximum value. + */ +#undef TIMER_MAX + +/* + * TIMER_RATE is the rate of the timer in ticks per second. It is used to + * calculate percent cpu usage. + */ #define TIMER_RATE 1000000 + +/* + * TIMER_HIGH_UNIT is the unit for high_bits in terms of low_bits. + * Setting it to TIMER_RATE makes the high unit seconds. + */ #define TIMER_HIGH_UNIT TIMER_RATE + +/* + * TIMER_ADJUST is used to adjust the value of a timer after it has been + * copied into a time_value_t. No adjustment is needed if high_bits is in + * seconds. + */ #undef TIMER_ADJUST -#else STAT_TIME +/* + * MACHINE_TIMER_ROUTINES should defined if the timer routines are + * implemented in machine-dependent code (e.g. assembly language). + */ +#undef MACHINE_TIMER_ROUTINES + +#else /* STAT_TIME */ /* * Machine dependent definitions based on hardware support. */ #include -#endif STAT_TIME +#endif /* STAT_TIME */ /* * Definitions for accurate timers. high_bits_check is a copy of @@ -99,19 +123,21 @@ typedef struct timer_save timer_save_dat #if STAT_TIME #define start_timer(timer) #define timer_switch(timer) -#else STAT_TIME -extern void start_timer(); -extern void timer_switch(); -#endif STAT_TIME - -extern void timer_read(); -extern void thread_read_times(); -extern unsigned timer_delta(); +#else /* STAT_TIME */ +extern void start_timer(timer_t); +extern void timer_switch(timer_t); +#endif /* STAT_TIME */ + +extern void timer_read(timer_t, time_value_t *); +extern void thread_read_times(thread_t, time_value_t *, time_value_t *); +extern unsigned timer_delta(timer_t, timer_save_t); +extern void timer_normalize(timer_t); +extern void timer_init(timer_t); #if STAT_TIME /* * Macro to bump timer values. - */ + */ #define timer_bump(timer, usec) \ MACRO_BEGIN \ (timer)->low_bits += usec; \ @@ -120,15 +146,15 @@ MACRO_BEGIN \ } \ MACRO_END -#else STAT_TIME +#else /* STAT_TIME */ /* * Exported hardware interface to timers */ -extern void time_trap_uentry(); -extern void time_trap_uexit(); -extern timer_t time_int_entry(); -extern void time_int_exit(); -#endif STAT_TIME +extern void time_trap_uentry(unsigned); +extern void time_trap_uexit(int); +extern timer_t time_int_entry(unsigned, timer_t); +extern void time_int_exit(unsigned, timer_t); +#endif /* STAT_TIME */ /* * TIMER_DELTA finds the difference between a timer and a saved value, @@ -142,7 +168,7 @@ extern void time_int_exit(); #define TIMER_DELTA(timer, save, result) \ MACRO_BEGIN \ - register unsigned temp; \ + unsigned temp; \ \ temp = (timer).low_bits; \ if ((save).high != (timer).high_bits_check) { \ @@ -154,4 +180,8 @@ MACRO_BEGIN \ } \ MACRO_END -#endif _KERN_TIMER_H_ +extern void init_timers(void); + +void timer_init(timer_t this_timer); + +#endif /* _KERN_TIMER_H_ */