Re: How can I determine ram in C ?

From: Randolph J. Herber (herber_at_dcdrjh.fnal.gov)
Date: 08/29/03


Date: Fri, 29 Aug 2003 19:24:23 GMT

The following header lines retained to effect attribution:
|Date: Fri, 29 Aug 2003 02:34:36 +0100
|From: "Dr. David Kirkby" <drkirkby@ntlworld.com>
|Subject: How can I determine ram in C ?
|To: info-iris-admin@ARL.ARMY.MIL

|I know the hinv command gives a lot of information about a machine,
|but is there a way to get the same information in C ? I can get the
|number of CPUs online using sysconf, but I can't find a way to get the
|ram. Other information, such as CPU, FPU, cache sizes would be useful
|too.

|I guess the source for hinv would be nice, but I suspect its possible
|to get the information without that.

|Dr. David Kirkby,
|Senior Research Fellow,
|Department of Medical Physics,
|University College London,
|11-20 Capper St, London, WC1E 6JA.
|Website: http://www.medphys.ucl.ac.uk/~davek
|Author of 'atlc' http://atlc.sourceforge.net/

Yes, RTFM.

man-k inentory yields the following among others:

getinvent, setinvent, endinvent, scaninvent, getinvent_r, setinvent_r, endinvent_r (3) - get hardware inventory entry

in man getinvent, note the ``#include <invent.h>'':
in /usr/include/invent.h, note the ``#include <sys/invent.h>'':
in /usr/include/sys/invent.h, note the following:

/* types for class memory */
/* NB. the states for class memory are sizes in bytes */
#define INV_MAIN 1
#define INV_DCACHE 3
#define INV_ICACHE 4
#define INV_WBUFFER 5
#define INV_SDCACHE 6
#define INV_SICACHE 7
#define INV_SIDCACHE 8
#define INV_MAIN_MB 9
#define INV_HUBSPC 10 /* HUBSPC */
#define INV_TIDCACHE 11

Randolph J. Herber, herber@fnal.gov, +1 630 840 2966, CD/CDFTF PK-149F,
Mail Stop 318, Fermilab, Kirk & Pine Rds., PO Box 500, Batavia, IL 60510-0500,
USA. (Speaking for myself and not for US, US DOE, FNAL nor URA.) (Product,
trade, or service marks herein belong to their respective owners.)



Relevant Pages

  • Re: Why does code fail to find *exact* amouut of RAM??
    ... "Dr. David Kirkby" wrote: ... > Dividing by the number of bytes in a Mb, gives the RAM in Mb ... Commercial UNIX's - all report the *exact* physical memory. ... Department of Medical Physics, ...
    (comp.os.linux.development.system)
  • Re: Why does code fail to find *exact* amouut of RAM??
    ... "Dr. David Kirkby" wrote: ... > Dividing by the number of bytes in a Mb, gives the RAM in Mb ... Commercial UNIX's - all report the *exact* physical memory. ... Department of Medical Physics, ...
    (comp.unix.solaris)
  • Re: Why does code fail to find *exact* amouut of RAM??
    ... "Dr. David Kirkby" wrote: ... > Dividing by the number of bytes in a Mb, gives the RAM in Mb ... Commercial UNIX's - all report the *exact* physical memory. ... Department of Medical Physics, ...
    (comp.sys.hp.hpux)