FreeBSD/sys/kern/kern_tc.c
/*
 * This function gets called every 16 seconds on only one designated
 * CPU in the system from hardclock() via cpu_tick_calibration()().
 *
 * Whenever the real time clock is stepped we get called with reset=1
 * to make sure we handle suspend/resume and similar events correctly.
 */
This function gets called every 16 seconds on only one designated
CPU in the system from hardclock() via cpu_tick_calibration()().

Whenever the real time clock is stepped we get called with reset=1
to make sure we handle suspend/resume and similar events correctly.
This function gets called every 16 seconds on only one designated CPU in the system from hardclock () via cpu_tick_calibration () () . Whenever the real time clock is stepped we get called with reset = 1 to make sure we handle suspend / resume and similar events correctly .
static void
cpu_tick_calibrate(int reset)
{
	static uint64_t c_last;
	uint64_t c_this, c_delta;
	static struct bintime  t_last;
	struct bintime t_this, t_delta;
	uint32_t divi;
	if (reset) {
		t_last.sec = 0;
		return;
	}
	if (!cpu_tick_variable)
		return;
	getbinuptime(&t_this);
	c_this = cpu_ticks();
	if (t_last.sec != 0) {
		c_delta = c_this - c_last;
		t_delta = t_this;
		bintime_sub(&t_delta, &t_last);
		divi = t_delta.sec << 20;
		divi |= t_delta.frac >> (64 - 20);
		c_delta <<= 20;
		c_delta /= divi;
		if (c_delta > cpu_tick_frequency) {
			if (0 && bootverbose)
				printf("cpu_tick increased to %ju Hz\n",
				    c_delta);
			cpu_tick_frequency = c_delta;
		}
	}
	c_last = c_this;
	t_last = t_this;
}
static void cpu_tick_calibrate ( int reset ) { static uint64_t c_last ; uint64_t c_this , c_delta ; static struct bintime t_last ; struct bintime t_this , t_delta ; uint32_t divi ; if ( reset ) { t_last . sec = 0 ; return ; } if ( ! cpu_tick_variable ) return ; getbinuptime ( & t_this ) ; c_this = cpu_ticks ( ) ; if ( t_last . sec != 0 ) { c_delta = c_this - c_last ; t_delta = t_this ; bintime_sub ( & t_delta , & t_last ) ; divi = t_delta . sec << 20 ; divi |= t_delta . frac >> ( 64 - 20 ) ; c_delta <<= 20 ; c_delta /= divi ; if ( c_delta > cpu_tick_frequency ) { if ( 0 && bootverbose ) printf ( " \n " , c_delta ) ; cpu_tick_frequency = c_delta ; } } c_last = c_this ; t_last = t_this ; }
This function gets called every 16 seconds on only one designated
 CPU in the system from hardclock() via cpu_tick_calibration()().
This function gets called every 16 seconds on only one designated CPU in the system from hardclock () via cpu_tick_calibration () () .
/* The clock was stepped, abort & reset */ /* we don't calibrate fixed rate cputicks */ /*
		 * Headroom:
		 * 	2^(64-20) / 16[s] =
		 * 	2^(44) / 16[s] =
		 * 	17.592.186.044.416 / 16 =
		 * 	1.099.511.627.776 [Hz]
		 */