OpenBSD manual page server

Manual Page Search Parameters

TC_INIT(9) Kernel Developer's Manual TC_INIT(9)

tc_initmachine-independent binary timescale

#include <sys/timetc.h>

tc_init(struct timecounter *tc);

The timecounter interface is a machine-independent implementation of a binary timescale using whatever hardware support is at hand for tracking time.

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;
	u_int 			tc_counter_mask;
	u_int64_t		tc_frequency;
	char			*tc_name;
	int			tc_quality;
	void			*tc_priv;
	struct timecounter	*tc_next;

The fields of the timecounter structure are described below.

u_int (*tc_get_timecount)(struct timecounter *)
This function reads the counter. It is not required to mask any unimplemented bits out, as long as they are constant.
This mask should mask off any unimplemented bits.
Frequency of the counter in Hz.
Name of the timecounter. Can be any null-terminated string.
Used to determine if this timecounter is better than another timecounter - higher means better. If this field is negative, the counter is only used at explicit request.
Pointer to the timecounter's private parts.
For internal use.

To register a new timecounter, the hardware device driver should fill a timecounter structure with appropriate values and call the () function, giving a pointer to the structure as a tc parameter.

The timecounter framework is implemented in the file 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,

The timecounter interface first appeared in OpenBSD 3.6.

February 4, 2023 OpenBSD-current