| TIMECOUNTER(9) | Kernel Developer's Manual | TIMECOUNTER(9) | 
timecounter, tc_init —
#include <sys/timetc.h>
void
  
  tc_init(struct
    timecounter *tc);
A timecounter is a binary counter which has two properties:
The interface between the hardware which implements a timecounter and the machine-independent code which uses this to keep track of time is a timecounter structure:
struct timecounter {
	timecounter_get_t	*tc_get_timecount;
	timecounter_pps_t	*tc_poll_pps;
	u_int 			tc_counter_mask;
	uint64_t		tc_frequency;
	const char		*tc_name;
	int			tc_quality;
	void			*tc_priv;
	struct timecounter	*tc_next;
}
The fields of the timecounter structure are described below.
(*tc_get_timecount)(struct
    timecounter *)(*tc_poll_pps)(struct timecounter
    *)NULL.
      It will be called whenever the timecounter is rewound, and is intended to
      check for PPS events. Normal hardware does not need it but timecounters
      which latch PPS in hardware do.To register a new timecounter, the hardware device driver should
    fill a timecounter structure with appropriate values
    and call the tc_init() function, giving a pointer to
    the structure as a tc parameter.
struct bintime {
	time_t	sec;
	uint64_t frac;
}
The sec field records the number of seconds as well as the tv_sec field in the traditional UNIX timeval and timespec structures, described in timeval(3).
The frac field records fractional seconds
    represented in a fully 64 bit integer, i.e. it goes all the way from
    0 through 0xFFFFFFFFFFFFFFFF
    per each second. The effective resolution of the frac
    value depends on a frequency of the machine dependent timecounter
  source.
The bintime format is a binary number, not a pseudo-decimal number, so it can be used as a simple binary counter without expensive 64 bit arithmetic.
<sys/time.h>.
Poul-Henning Kamp, Timecounters: Efficient and precise timekeeping in SMP kernels, Proceedings of EuroBSDCon 2002, Amsterdam, http://phk.freebsd.dk/pubs/timecounter.pdf, 15-17 November, 2002.
| September 18, 2021 | NetBSD 10.0 |