Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* Re: How can I find the real memory of a Digital Unix 3.x system
       [not found] <44fe6o$erk@newsbf02.news.aol.com>
@ 1995-09-29  4:00 ` Peter Delgado
  1995-09-30  4:00 ` Dan Pop
  1 sibling, 0 replies; 2+ messages in thread
From: Peter Delgado @ 1995-09-29  4:00 UTC (permalink / raw)


Here's code that will find the amount of RAM on a Digital UNIX
system.    I had to cast the integer address to a char to silence
the compiler warning.  Although the man page for getsysinfo indicates
a integer pointer is expected for the argument, the compiler insists
on a character pointer.  I didn't really have the time to investigate the 
discrepancy so it stayed.  Perhaps you might want to look at it!

Compile with cc -std1   or cc -migrate (to get better error messages)


#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <sys/sysinfo.h>
#include <machine/hal_sysinfo.h>

int main(int argc, char *argv[])
{
int     TotalMemory;


if (getsysinfo(GSI_PHYSMEM,(char *)&TotalMemory,(unsigned
                          long)(sizeof(int)),0,NULL) !=-1)
   {
   TotalMemory += 512;
   fprintf(stdout,"Total Memory = %d MB\n",TotalMemory/1024);
   exit(0);
   }
perror("PHYSMEM");
exit(1);
}

--Pete

-------------------------------------------------------------------------------
Pete Delgado                                      The opinions expressed are
Software Development/Support Engineer             my own and do not reflect
Product Installation                              the official opinions of
Structural Dynamics Research Corporation          SDRC.
2000 Eastman Drive                                
Milford, Ohio 45150
                                                  No user 
                                                  servicable parts inside!
e-mail:  Peter.Delgado@sdrc.com

-------------------------------------------------------------------------------




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How can I find the real memory of a Digital Unix 3.x system
       [not found] <44fe6o$erk@newsbf02.news.aol.com>
  1995-09-29  4:00 ` How can I find the real memory of a Digital Unix 3.x system Peter Delgado
@ 1995-09-30  4:00 ` Dan Pop
  1 sibling, 0 replies; 2+ messages in thread
From: Dan Pop @ 1995-09-30  4:00 UTC (permalink / raw)


In <44fe6o$erk@newsbf02.news.aol.com> anjone@aol.com (ANJONE) writes:

>Could you please let me know how I can do that -- instead of
>/usr/adm/messages file, I would prefer some C programming, API/System call
>or command.

#include <stdio.h>
#include <sys/sysinfo.h>

main()
{
    int memsize;

    getsysinfo(GSI_PHYSMEM, (caddr_t)&memsize, sizeof(memsize), NULL, NULL);
    printf("Memory size: %d KB\n", memsize);
    return 0;
}

Dan
--
Dan Pop
CERN, CN Division
Email: Dan.Pop@mail.cern.ch 
Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1995-09-30  4:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <44fe6o$erk@newsbf02.news.aol.com>
1995-09-29  4:00 ` How can I find the real memory of a Digital Unix 3.x system Peter Delgado
1995-09-30  4:00 ` Dan Pop

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox