Date: Mon, 1 Dec 1997 22:17:39 -0500 (EST) From: David Petrou <dpetrou@KINCLAITH.PDL.CS.CMU.EDU> To: freebsd-stable@freebsd.org Subject: RE: CPU Load Message-ID: <199712020317.TAA19733@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
It seems that there's a lot of misinformation being posted here re:
cpu load. Just look at the relevant code from vm/vm_meter.c:
static void
loadav(struct loadavg *avg)
{
register int i, nrun;
register struct proc *p;
for (nrun = 0, p = allproc.lh_first; p != 0; p = p->p_list.le_next) {
switch (p->p_stat) {
case SSLEEP:
if (p->p_priority > PZERO || p->p_slptime != 0)
continue;
/* fall through */
case SRUN:
case SIDL:
nrun++;
}
}
for (i = 0; i < 3; i++)
avg->ldavg[i] = (cexp[i] * avg->ldavg[i] +
nrun * FSCALE * (FSCALE - cexp[i])) >> FSHIFT;
}
The important part is nrun... If a process is in SRUN or SIDL or it
has a higher priority (lower numerically) than PZERO _AND_ it has
slept less than a second, the process is counted. (That last clause
covers fast disk operations...)
David
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199712020317.TAA19733>
