| TC_INIT(9) | Kernel Developer's Manual | TC_INIT(9) |
tc_init —
timecounting subsystem
#include
<sys/timetc.h>
void
tc_init(struct
timecounter *tc);
The timecounting subsystem implements a uniform interface to timekeeping hardware, measures the passage of time, and implements the kernel's software clocks (see microtime(9) for details).
A hardware clock is suitable for counting time if it meets the following requirements:
Hardware clocks are described with a timecounter structure:
struct timecounter {
u_int (*tc_get_timecount)(struct timecounter *);
u_int tc_counter_mask;
u_int64_t tc_frequency;
char *tc_name;
int tc_quality;
void *tc_priv;
u_int tc_user;
};
(*tc_get_timecount)(struct
timecounter *)tc_get_timecount().NUL-terminated
string.tc_get_timecount().tc_get_timecount().To register a timecounter, a device driver
initializes the above-described fields of a
timecounter structure and calls
tc_init()
with a pointer to that structure as argument.
tc_init() may only be called during
autoconf.
sys/kern/kern_tc.c
amdpm(4), gscpm(4), ichpcib(4), viapm(4), hz(9), microtime(9)
Poul-Henning Kamp, Timecounter: Efficient and precise timekeeping in SMP kernels, The FreeBSD Project, https://papers.freebsd.org/2002/phk-timecounters.files/timecounter.pdf, 2002.
The timecounting subsystem first appeared in FreeBSD 3.0. It was ported to OpenBSD 3.6.
Poul-Henning Kamp
| April 2, 2023 | openbsd |