From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fcda7,ea04c1effb701bf3,start X-Google-Attributes: gidfcda7,public X-Google-Thread: f88e1,ea04c1effb701bf3,start X-Google-Attributes: gidf88e1,public X-Google-Thread: 1164f8,ea04c1effb701bf3,start X-Google-Attributes: gid1164f8,public X-Google-Thread: f6653,ea04c1effb701bf3,start X-Google-Attributes: gidf6653,public X-Google-ArrivalTime: 1994-11-21 14:55:44 PST Path: nntp.gmd.de!xlink.net!sol.ctr.columbia.edu!howland.reston.ans.net!swrinde!sgiblab!uhog.mit.edu!news.mathworks.com!newshost.marcam.com!uunet!cichlid.com!not-for-mail From: aab@cichlid.com (Andy Burgess) Newsgroups: comp.sys.hp.hpux,comp.sys.sun.misc,comp.sys.dec,alt.sys.sun Subject: How to check swap space from C Date: 21 Nov 1994 14:55:44 -0800 Organization: Contract C programmer, no-cost UUCP host, gardener, cook Message-ID: <3ar8hg$ov6@loach.cichlid.com> NNTP-Posting-Host: loach.cichlid.com Xref: nntp.gmd.de comp.sys.hp.hpux:16892 comp.sys.sun.misc:18174 comp.sys.dec:19934 alt.sys.sun:3079 Does anyone know how to determine free swap space from C code on any of the following platforms: hp: HP-UX A.09.05 A 9000/715 2012724640 sun4: SunOS 4.1.3 sun4: Solaris dec: ULTRIX 4.4 We did manage to get this to work on our sgis, os versions 4 and 5. We know about the hack to mmap large files of varying sizes but it can cause out of swap errors in other processes. We'll use it as a last resort. SUN4(SunOS4.1) & DEC: We have no idea. HP: HP has a pstat_getswap call mentioned in pstat.h but we can't find any other docs. HP tech support suggested doing system("swapinfo") which is too slow for our application. SOLARIS: Solaris has the swapctl lib function but the following code that uses it print 'swapctl: Bad address' Solaris code follows: ------------------------------------------------------------------- #include #include #include #include #define SIZE 200 void main() { int i, n, swap_free=0; struct { int swt_n; struct swapent swt_ent[SIZE]; } table; table.swt_n = SIZE; n = swapctl(SC_LIST, &table); if(n == -1) perror("swapctl"), exit(1); printf("Got %d\n", n); for(i=0; i