lload for xenix
Clemens Schrimpe
csch at netcs.UUCP
Thu Jun 1 11:02:03 AEST 1989
Ha! Thanks to SCO's freaky developers, the load-average stuff is already
included in SCO 2.3.1!
You'll find the label '_avenrun' in /xenix, which is somewhat declared as
unsigned short avenrun[3].
As far, as I have found out (try looking into the 'w' command), they
use a strange floating-point notation for each value. The integer part
is in the higher 8 bits, while the fractional part is in the lower 8 bits.
(That's how 'w' will diplay 'em)
Anyhow - this is how one of our utilities gets the load average:
(simple collection of various subroutines)
#include <sys/a.out.h>
#include <fcntl.h>
print_average ()
{
int fd;
struct nlist nl;
unsigned short loadav[3];
if ((fd = open ("/dev/kmem", O_RDONLY)) == -1)
return;
strcpy(nl.n_name, "_avenrun");
nlist ("/xenix", &nl);
if (nl.n_type == 0 || nl.n_value == 0)
return;
if (lseek (fd, nl.n_value, 0) == -1)
return;
if (read (fd, loadav, sizeof (loadav)) != sizeof (loadav))
return 0;
printf (" %2.2f %2.2f %2.2f\n", (double)loadav[0]/256.,
(double)loadav[1]/256., (double)loadav[2]/256.);
}
Any corrections from SCO welcome - but guys: better correct your 'w' too
then :-)
greeting the whole SCO community on the net,
Clemens Schrimpe, netCS GmbH Informationstechnik Berlin
PS:
By looking more deeply into the kernel's tables you'll also find a fully
working select() and other fancy stuff in Xenix 2.3.1! (thnx 2 sco)
(even though the PTY's have a minor bug, which will prevent the select()
from working with them - but this is a fast fix ...)
--
UUCP: csch at netcs BITNET: csch at db0tui6.BITNET
ARPA/NSF: csch at garp.mit.edu PSI: PSI%26245300033047::CSCH
PHONE: +49-30-24 42 37 FAX: +49-30-24 38 00
BTX: 0303325016-0003 TELEX: 186672 net d
More information about the Alt.sources
mailing list