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)); }
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)); }