FreeBSD/sys/kern/kern_clocksource.c
/*
 * Load new value into hardware timer.
 */
Load new value into hardware timer.
Load new value into hardware timer .
static void
loadtimer(sbintime_t now, int start)
{
	struct pcpu_state *state;
	sbintime_t new;
	sbintime_t *next;
	uint64_t tmp;
	int eq;
	if (timer->et_flags & ET_FLAGS_PERCPU) {
		state = DPCPU_PTR(timerstate);
		next = &state->nexttick;
	} else
		next = &nexttick;
	if (periodic) {
		if (start) {
			tmp = now % timerperiod;
			new = timerperiod - tmp;
			if (new < tmp)		
				new += timerperiod;
			CTR5(KTR_SPARE2, "load p at %d:   now %d.%08x first in %d.%08x",
			    curcpu, (int)(now >> 32), (u_int)(now & 0xffffffff),
			    (int)(new >> 32), (u_int)(new & 0xffffffff));
			*next = new + now;
			et_start(timer, new, timerperiod);
		}
	} else {
		new = getnextevent();
		eq = (new == *next);
		CTR4(KTR_SPARE2, "load at %d:    next %d.%08x eq %d",
		    curcpu, (int)(new >> 32), (u_int)(new & 0xffffffff), eq);
		if (!eq) {
			*next = new;
			et_start(timer, new - now, 0);
		}
	}
}
static void loadtimer ( sbintime_t now , int start ) { struct pcpu_state * state ; sbintime_t new ; sbintime_t * next ; uint64_t tmp ; int eq ; if ( timer -> et_flags & ET_FLAGS_PERCPU ) { state = DPCPU_PTR ( timerstate ) ; next = & state -> nexttick ; } else next = & nexttick ; if ( periodic ) { if ( start ) { tmp = now % timerperiod ; new = timerperiod - tmp ; if ( new < tmp ) new += timerperiod ; CTR5 ( KTR_SPARE2 , " " , curcpu , ( int ) ( now >> 32 ) , ( u_int ) ( now & 0xffffffff ) , ( int ) ( new >> 32 ) , ( u_int ) ( new & 0xffffffff ) ) ; * next = new + now ; et_start ( timer , new , timerperiod ) ; } } else { new = getnextevent ( ) ; eq = ( new == * next ) ; CTR4 ( KTR_SPARE2 , " " , curcpu , ( int ) ( new >> 32 ) , ( u_int ) ( new & 0xffffffff ) , eq ) ; if ( ! eq ) { * next = new ; et_start ( timer , new - now , 0 ) ; } } }
Load new value into hardware timer.
Load new value into hardware timer .
/*
			 * Try to start all periodic timers aligned
			 * to period to make events synchronous.
			 */ /* Left less then passed. */