How to get avenrun (or: how to read vars from kmem)
Doctor Software
jmb at patton.wpd.sgi.com
Thu Nov 29 03:28:40 AEST 1990
In article <amoss.659280210 at shum>, amoss at shum.UUCP (Amos Shapira) writes:
> I need to write a program which will get the load avarage (to port
> a batch system).
The easiest way to do this is to use the sysmp(2) call. Peruse the
header file /usr/include/sys/sysmp.h, which gives the different commands
you can give as well. For instance, to get the kernel address of the
avenrun array:
avenrunp = sysmp(MP_KERNADDR, MPKA_AVENRUN);
avenrunp &= ~0x8000000;
This value can then be passed directly to lseek(2) on /dev/kmem, and you
can then read out the array.
Another possibility is to use the same sequence above to get the address
of avenrun, but instead of seeking and reading on /dev/kmem, just use
the mmap(2) system call to map the kernel into your address space. Then
you can read avenrun directly without any system call overhead.
-- Jim Barton
Silicon Graphics Computer Systems
jmb at sgi.com
More information about the Comp.sys.sgi
mailing list