FreeBSD/sys/kern/sched_ule.c
/*
 * Update the percent cpu tracking information when it is requested or
 * the total history exceeds the maximum.  We keep a sliding history of
 * tick counts that slowly decays.  This is less precise than the 4BSD
 * mechanism since it happens with less regular and frequent events.
 */
Update the percent cpu tracking information when it is requested or
the total history exceeds the maximum.  We keep a sliding history of
tick counts that slowly decays.  This is less precise than the 4BSD
mechanism since it happens with less regular and frequent events.
Update the percent cpu tracking information when it is requested or the total history exceeds the maximum . We keep a sliding history of tick counts that slowly decays . This is less precise than the 4BSD mechanism since it happens with less regular and frequent events .
static void
sched_pctcpu_update(struct td_sched *ts, int run)
{
	int t = ticks;
	if (t - ts->ts_ltick >= SCHED_TICK_TARG) {
		ts->ts_ticks = 0;
		ts->ts_ftick = t - SCHED_TICK_TARG;
	} else if (t - ts->ts_ftick >= SCHED_TICK_MAX) {
		ts->ts_ticks = (ts->ts_ticks / (ts->ts_ltick - ts->ts_ftick)) *
		    (ts->ts_ltick - (t - SCHED_TICK_TARG));
		ts->ts_ftick = t - SCHED_TICK_TARG;
	}
	if (run)
		ts->ts_ticks += (t - ts->ts_ltick) << SCHED_TICK_SHIFT;
	ts->ts_ltick = t;
}
static void sched_pctcpu_update ( struct td_sched * ts , int run ) { int t = ticks ; if ( t - ts -> ts_ltick >= SCHED_TICK_TARG ) { ts -> ts_ticks = 0 ; ts -> ts_ftick = t - SCHED_TICK_TARG ; } else if ( t - ts -> ts_ftick >= SCHED_TICK_MAX ) { ts -> ts_ticks = ( ts -> ts_ticks / ( ts -> ts_ltick - ts -> ts_ftick ) ) * ( ts -> ts_ltick - ( t - SCHED_TICK_TARG ) ) ; ts -> ts_ftick = t - SCHED_TICK_TARG ; } if ( run ) ts -> ts_ticks += ( t - ts -> ts_ltick ) << SCHED_TICK_SHIFT ; ts -> ts_ltick = t ; }
Update the percent cpu tracking information when it is requested or
 the total history exceeds the maximum.
Update the percent cpu tracking information when it is requested or the total history exceeds the maximum .