Cannot retrieve main memory size using sysmp

sgitcl

New member
Jan 8, 2026
7
6
3
Munich
www.sgitcl.tcl3d.org
According to the "Topics in IRIX Programming" manual, it should be fairly easy to determine the amount of physical and free main memory using the sysmp system call.
But when I execute the following simple test program:
#include <stdio.h>

#include <sys/types.h>
#include <sys/sysmp.h>
#include <sys/sysinfo.h>

int main(int argc, char *argv[])
{
int retVal;
struct rminfo rmstruct = { 123 };

retVal = sysmp(MP_KERNADDR, MPSA_RMINFO, &rmstruct);
printf("retVal=%d\n", retVal);
printf("freemem=%d\n",rmstruct.freemem);
printf("availsmem=%d\n",rmstruct.availsmem);
printf("availrmem=%d\n",rmstruct.availrmem);
printf("bufmem=%d\n",rmstruct.bufmem);
printf("physmem=%d\n",rmstruct.physmem);
printf("dchunkpages=%d\n",rmstruct.dchunkpages);
printf("pmapmem=%d\n",rmstruct.pmapmem);
printf("strmem=%d\n",rmstruct.strmem);
printf("chunkpages=%d\n",rmstruct.chunkpages);
printf("dpages=%d\n",rmstruct.dpages);
printf("emptymem=%d\n",rmstruct.emptymem);
printf("ravailrmem=%d\n",rmstruct.ravailrmem);

return 0;
}

I get the following results:
retVal=0
freemem=123
availsmem=0
availrmem=0
bufmem=0
physmem=0
dchunkpages=0
pmapmem=0
strmem=0
chunkpages=0
dpages=0
emptymem=0
ravailrmem=0

The sysmp call succeeds (return value: 0), but all rminfo fields are set to zero with the exception of field freemem, which is left untouched.
Any hints, what is going wrong?

P.S.: Tested on an O2 and a MAME-Indy running IRIX 6.5.22 and gcc 3.4.6.
 
I did not test the sysmp call, but this is how I read memory and swap info in the system load monitor sginet-client:

Code:
    struct statfs fs;
    int rc = statfs("/proc/0000000001", &fs, sizeof(struct statfs), 0);
    if (rc == 0) {
        memTotal = (fs.f_blocks * fs.f_bsize) / 1024;
        memAvail = (fs.f_bfree * fs.f_bsize) / 1024;
        memUsed = memTotal - memAvail;
        machine->totalMem = memTotal;
        machine->availableMem = memAvail != 0 ? MINIMUM(memAvail, memTotal) : memAvail;
        machine->usedMem = memUsed;
        // Query swap data
        rc1 = swapctl(SC_GETSWAPMAX, &swapmax);
        rc2 = swapctl(SC_GETFREESWAP, &swapfree);
        if (rc1 + rc2 == 0) {
            machine->totalSwap = (swapmax * 512 / 1024);
            machine->usedSwap = ((swapmax - swapfree) * 512 / 1024);
        }
    }

and in the hinv uploader I use invent.h

Code:
#include <invent.h>

inventory_t* iptr;
setinvent();
iptr = getinvent();
while (iptr) {
    if (iptr->class == INV_MEMORY) ....
 
Last edited:

About us

  • Silicon Graphics User Group (SGUG) is a community for users, developers, and admirers of Silicon Graphics (SGI) products. We aim to be a friendly hobbyist community for discussing all aspects of SGIs, including use, software development, the IRIX Operating System, and troubleshooting, as well as facilitating hardware exchange.

User Menu