From torek@horse.ee.lbl.gov Sat Nov 30 11:33:27 1991 From: torek@horse.ee.lbl.gov (Chris Torek) Newsgroups: comp.unix.programmer Subject: Re: How can I find the system load in a C program? Date: 30 Nov 91 12:34:52 GMT Reply-To: torek@horse.ee.lbl.gov (Chris Torek) Organization: Lawrence Berkeley Laboratory, Berkeley X-Local-Date: Sat, 30 Nov 91 04:34:52 PST In article <11904.Nov2806.30.0091@kramden.acf.nyu.edu> brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes: >It varies. On most machines it's an array of three doubles. On a Sun, >it's an array of three longs, with scale factor 256. Same for >Ultrix/MIPS. On MORE/BSD it's three longs with scale 2048. On the >Astronautics ZS it's three longs with scale 65536. In BSD 4.4 there >isn't even an avenrun any more---it's averunnable. ... which is an array of 3 `fixpt_t's with scale FSCALE, which is 2 to the FSHIFT power. FSHIFT is 11, giving scale 2048. All of this is subject to change without notice, since 4.4BSD does not exist yet. The other systems people forgot an important design rule: If you make an otherwise invisible change to something that will cause programs to break mysteriously, make an appropriate visible change, so that programs will break unmysteriously. In this case the BSD folks may have got this right only because VAXen handily provide a backwards- compatibility `avenrun' array. -- In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 510 486 5427) Berkeley, CA Domain: torek@ee.lbl.gov From belal@sco.COM Tue Sep 29 15:25:12 1992 From: belal@sco.COM (Bela Lubkin) Newsgroups: biz.sco.general Subject: Re: SCO load average Date: 29 Sep 92 00:56:59 GMT Organization: [resent by] The SCOGEN gateway and Propagation Society Resent-From: mmdf@xenitec.on.ca Submit-To: scogen@xenitec.on.ca Cc: scogen@xenitec.ON.CA Precedence: bulk Eduard Vopicka asked: > Please does any one know where /usr/bin/w takes the "Load average:" > data from, e.g. the names and types of kernel variables and the > algorithm used to calculate the load average? The load average is maintained by the kernel scheduler. The kernel variable is declared as "short avenrun[3]"; w (uptime) nlist's the kernel, then reads this variable out of /dev/kmem. avenrun is calculated as a running average of the number of processes which are in the run queue (thus, either ready to run or currently running) plus the number of processes that are sleeping at non-interruptible priorities. This latter class is why certain daemons (e.g. nfsd processes, and some of the processes associated with LAN Manager Server) increase the load average by 1.0 each, without really impacting system performance. The three elements of avenrun are the running average over the last minute, last 5 minutes, and last 15 minutes. >Bela Lubkin< Support engineer, The Santa Cruz Operation