FreeBSD/sys/kern/sched_4bsd.c
/*
 * Calculates the contribution to the thread cpu usage for the latest
 * (unfinished) second.
 */
Calculates the contribution to the thread cpu usage for the latest
(unfinished) second.
Calculates the contribution to the thread cpu usage for the latest ( unfinished ) second .
fixpt_t
sched_pctcpu_delta(struct thread *td)
{
	struct td_sched *ts;
	fixpt_t delta;
	int realstathz;
	THREAD_LOCK_ASSERT(td, MA_OWNED);
	ts = td_get_sched(td);
	delta = 0;
	realstathz = stathz ? stathz : hz;
	if (ts->ts_cpticks != 0) {
#if	(FSHIFT >= CCPU_SHIFT)
		delta = (realstathz == 100)
		    ? ((fixpt_t) ts->ts_cpticks) <<
		    (FSHIFT - CCPU_SHIFT) :
		    100 * (((fixpt_t) ts->ts_cpticks)
		    << (FSHIFT - CCPU_SHIFT)) / realstathz;
#else
		delta = ((FSCALE - ccpu) *
		    (ts->ts_cpticks *
		    FSCALE / realstathz)) >> FSHIFT;
#endif
	}
	return (delta);
}
fixpt_t sched_pctcpu_delta ( struct thread * td ) { struct td_sched * ts ; fixpt_t delta ; int realstathz ; THREAD_LOCK_ASSERT ( td , MA_OWNED ) ; ts = td_get_sched ( td ) ; delta = 0 ; realstathz = stathz ? stathz : hz ; if ( ts -> ts_cpticks != 0 ) { #if ( FSHIFT >= CCPU_SHIFT ) delta = ( realstathz == 100 ) ? ( ( fixpt_t ) ts -> ts_cpticks ) << ( FSHIFT - CCPU_SHIFT ) : 100 * ( ( ( fixpt_t ) ts -> ts_cpticks ) << ( FSHIFT - CCPU_SHIFT ) ) / realstathz ; #else delta = ( ( FSCALE - ccpu ) * ( ts -> ts_cpticks * FSCALE / realstathz ) ) >> FSHIFT ; #endif } return ( delta ) ; }
Calculates the contribution to the thread cpu usage for the latest
 (unfinished) second.
Calculates the contribution to the thread cpu usage for the latest ( unfinished ) second .