Path: utzoo!mnetor!uunet!husc6!bloom-beacon!gatech!udel!burdvax!bpa!cbmvax!vu-vlsi!lehi3b15!lxn!chris From: chris@lxn.UUCP (Christopher D. Orr) Newsgroups: comp.unix.questions Subject: Determining system memory Message-ID: <248@lxn.UUCP> Date: 30 Mar 88 20:18:57 GMT Organization: Alcyone Inc., Bethlehem PA Lines: 39 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 :-). Solution 1: The command 'wc -c /dev/mem' seems to work though it takes *FOREVER* on systems with large amounts on memory. Solution 2: The following 'C' program reports system memory much faster that Solution 1, but is still fairly slow: #include #include extern int errno; static char BUF[32768]; void main() { long int L; int M; M = open("/dev/mem",O_RDONLY); if (M < 0) { printf("Error: unable to open /dev/mem. errno=%d\n",errno); exit(1); } for (L=0;read(M,BUF,16384) == 16384 ;++L); printf("Memory Size: %ld\n",L * 16384); } Any other solutions are welcome (especially those that are faster :-) --- Christopher D. Orr | US MAIL: Alcyone Inc. UUCP: vu-vlsi\ | Lanark Building ihnp4 - !lehi3b15!lxn!chris | Center Valley, PA 18034 c11ux / | Voice: (215) 282-4525