Xref: utzoo comp.unix.xenix:6203 alt.sources:629 Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!amdcad!pyramid!tub!tmpmbx!netcs!csch From: csch@netcs.UUCP (Clemens Schrimpe) Newsgroups: comp.unix.xenix,alt.sources Subject: Re: lload for xenix Keywords: lload xenix Lars_Pensj i286 Message-ID: <4790@netcs.UUCP> Date: 1 Jun 89 01:02:03 GMT References: <30067@conexch.UUCP> <1394@laura.UUCP> Reply-To: csch@netcs.UUCP (Clemens Schrimpe) Organization: netCS Kommunikationstechnik GmbH, Berlin Lines: 53 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 #include 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@netcs BITNET: csch@db0tui6.BITNET ARPA/NSF: csch@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