コード例 #1
0
ファイル: print.c プロジェクト: Freeaqingme/OpenBSD
double
getpcpu(const struct kinfo_proc *kp)
{
	double d;

	if (fscale == 0)
		return (0.0);

#define	fxtofl(fixpt)	((double)(fixpt) / fscale)

	/* XXX - I don't like this */
	if (kp->p_swtime == 0)
		return (0.0);
	if (rawcpu)
		return (100.0 * fxtofl(kp->p_pctcpu));

	d = kp->p_swtime * log(fxtofl(ccpu));
	if (d < -700.0)
		d = 0.0;		/* avoid IEEE underflow */
	else
		d = exp(d);
	if (d == 1.0)
		return (0.0);
	return (100.0 * fxtofl(kp->p_pctcpu) /
		(1.0 - d));
}
コード例 #2
0
ファイル: print.c プロジェクト: Open343/bitrig
double
getpcpu(const struct kinfo_proc *kp)
{
	if (fscale == 0)
		return (0.0);

#define	fxtofl(fixpt)	((double)(fixpt) / fscale)

	return (100.0 * fxtofl(kp->p_pctcpu));
}