Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!usc!ucsd!pacbell.com!ames!sgi!shinobu!odin!patton.wpd.sgi.com!jmb From: jmb@patton.wpd.sgi.com (Doctor Software) Newsgroups: comp.sys.sgi Subject: Re: How to get avenrun (or: how to read vars from kmem) Message-ID: <1990Nov28.162840.14177@odin.corp.sgi.com> Date: 28 Nov 90 16:28:40 GMT References: Sender: news@odin.corp.sgi.com (Net News) Reply-To: jmb@patton.wpd.sgi.com (Doctor Software) Distribution: comp Organization: Silicon Graphics Inc. Lines: 23 In article , amoss@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@sgi.com