Determining system memory

Danny Backx dannyb at kulcs.uucp
Mon Apr 4 23:42:30 AEST 1988


In article <248 at lxn.UUCP> chris at lxn.UUCP (Christopher D. Orr) writes:
>I have been trying to find a nice, clean way to determine system
>memory under SYS V 2.2.  I have come up with two solutions to this
>problem.  However, there must be a cleaner/faster way :-).

How about opening /dev/mem and seeking to the end ?
The manual entry for lseek(2) says the return value is the position you got at.
So, if you seek to the end (offset 0 relative to the EOF), the return value
of lseek should be the amount of memory your system has.

I don't know if this works on /dev/mem.  It works on ordinary files.
If your program works, this should, too.

The system call you should issue is :

	long	lseek(), pos ;

	pos = lseek(M, 0L, 2);

Don't forget the declaration of lseek() !!!

	Danny

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 Danny Backx                            |  mail: Katholieke Universiteit Leuven 
 Tel: +32 16 200656 x 3537              |        Dept. Computer Science
 E-mail: dannyb at kulcs.UUCP              |        Celestijnenlaan 200 A
         ... mcvax!prlb2!kulcs!dannyb   |        B-3030 Leuven
         dannyb at blekul60.BITNET         |        Belgium     



More information about the Comp.unix.questions mailing list