FreeBSD/sys/kern/kern_clocksource.c
/*
 * Handle all events for specified time on this CPU
 */
Handle all events for specified time on this CPU
Handle all events for specified time on this CPU
static int
handleevents(sbintime_t now, int fake)
{
	sbintime_t t, *hct;
	struct trapframe *frame;
	struct pcpu_state *state;
	int usermode;
	int done, runs;
	CTR3(KTR_SPARE2, "handle at %d:  now  %d.%08x",
	    curcpu, (int)(now >> 32), (u_int)(now & 0xffffffff));
	done = 0;
	if (fake) {
		frame = NULL;
		usermode = 0;
	} else {
		frame = curthread->td_intr_frame;
		usermode = TRAPF_USERMODE(frame);
	}
	state = DPCPU_PTR(timerstate);
	runs = 0;
	while (now >= state->nexthard) {
		state->nexthard += tick_sbt;
		runs++;
	}
	if (runs) {
		hct = DPCPU_PTR(hardclocktime);
		*hct = state->nexthard - tick_sbt;
		if (fake < 2) {
			hardclock_cnt(runs, usermode);
			done = 1;
		}
	}
	runs = 0;
	while (now >= state->nextstat) {
		state->nextstat += statperiod;
		runs++;
	}
	if (runs && fake < 2) {
		statclock_cnt(runs, usermode);
		done = 1;
	}
	if (profiling) {
		runs = 0;
		while (now >= state->nextprof) {
			state->nextprof += profperiod;
			runs++;
		}
		if (runs && !fake) {
			profclock_cnt(runs, usermode, TRAPF_PC(frame));
			done = 1;
		}
	} else
		state->nextprof = state->nextstat;
	if (now >= state->nextcallopt) {
		state->nextcall = state->nextcallopt = SBT_MAX;
		callout_process(now);
	}
	t = getnextcpuevent(0);
	ET_HW_LOCK(state);
	if (!busy) {
		state->idle = 0;
		state->nextevent = t;
		loadtimer(now, (fake == 2) &&
		    (timer->et_flags & ET_FLAGS_PERCPU));
	}
	ET_HW_UNLOCK(state);
	return (done);
}
static int handleevents ( sbintime_t now , int fake ) { sbintime_t t , * hct ; struct trapframe * frame ; struct pcpu_state * state ; int usermode ; int done , runs ; CTR3 ( KTR_SPARE2 , " " , curcpu , ( int ) ( now >> 32 ) , ( u_int ) ( now & 0xffffffff ) ) ; done = 0 ; if ( fake ) { frame = NULL ; usermode = 0 ; } else { frame = curthread -> td_intr_frame ; usermode = TRAPF_USERMODE ( frame ) ; } state = DPCPU_PTR ( timerstate ) ; runs = 0 ; while ( now >= state -> nexthard ) { state -> nexthard += tick_sbt ; runs ++ ; } if ( runs ) { hct = DPCPU_PTR ( hardclocktime ) ; * hct = state -> nexthard - tick_sbt ; if ( fake < 2 ) { hardclock_cnt ( runs , usermode ) ; done = 1 ; } } runs = 0 ; while ( now >= state -> nextstat ) { state -> nextstat += statperiod ; runs ++ ; } if ( runs && fake < 2 ) { statclock_cnt ( runs , usermode ) ; done = 1 ; } if ( profiling ) { runs = 0 ; while ( now >= state -> nextprof ) { state -> nextprof += profperiod ; runs ++ ; } if ( runs && ! fake ) { profclock_cnt ( runs , usermode , TRAPF_PC ( frame ) ) ; done = 1 ; } } else state -> nextprof = state -> nextstat ; if ( now >= state -> nextcallopt ) { state -> nextcall = state -> nextcallopt = SBT_MAX ; callout_process ( now ) ; } t = getnextcpuevent ( 0 ) ; ET_HW_LOCK ( state ) ; if ( ! busy ) { state -> idle = 0 ; state -> nextevent = t ; loadtimer ( now , ( fake == 2 ) && ( timer -> et_flags & ET_FLAGS_PERCPU ) ) ; } ET_HW_UNLOCK ( state ) ; return ( done ) ; }
Handle all events for specified time on this CPU
Handle all events for specified time on this CPU