From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII X-Google-Thread: f88e1,ea04c1effb701bf3 X-Google-Attributes: gidf88e1,public X-Google-Thread: f6653,ea04c1effb701bf3 X-Google-Attributes: gidf6653,public X-Google-Thread: 1164f8,ea04c1effb701bf3 X-Google-Attributes: gid1164f8,public X-Google-Thread: fcda7,ea04c1effb701bf3 X-Google-Attributes: gidfcda7,public X-Google-ArrivalTime: 1994-11-21 19:02:12 PST Path: nntp.gmd.de!dearn!blekul11!idefix.CS.kuleuven.ac.be!ub4b!EU.net!howland.reston.ans.net! vixen.cso.uiuc.edu!uwm.edu!uwvax!sinetnews!news.u-tokyo.ac.jp!wnoc-tyo-news!wnoc-sfc-news!news.dec-j!jrd.dec.com!funlwb.stl.dec.com!jac.zko.dec.com!nntpd.lkg.dec.com!nntpd2.cxo.dec.com!nabeth.cxo.dec.com!alan From: alan@nabeth.cxo.dec.com (Alan Rollow - Dr. File System's Home for Wayward Inodes.) Newsgroups: comp.sys.hp.hpux,comp.sys.sun.misc,comp.sys.dec,alt.sys.sun Subject: Re: How to check swap space from C Date: 22 Nov 1994 03:02:12 GMT Organization: Digital Equipment Corporation Distribution: world Message-ID: <3armvk$gms@nntpd2.cxo.dec.com> References: <3ar8hg$ov6@loach.cichlid.com> Reply-To: alan@nabeth.cxo.dec.com (Alan Rollow - Dr. File System's Home for Wayward Inodes.) NNTP-Posting-Host: nabeth.cxo.dec.com Xref: nntp.gmd.de comp.sys.hp.hpux:16897 comp.sys.sun.misc:18182 comp.sys.dec:19941 alt.sys.sun:3082 In article <3ar8hg$ov6@loach.cichlid.com>, aab@cichlid.com (Andy Burgess) writes: >Does anyone know how to determine free swap space from C code on any of the >following platforms: > >dec: ULTRIX 4.4 I've seen two algorithms used: 1. You need to read the resource map for the "swapmap"�and then add up the size for each element. 2. There is a data structure called swapu, defined in . This keeps track of how the swap space is used. One of the fields is the total in use. The amount free is the total available - total_used. The amount available is the sum of sizes in swdevt table. Finally, ULTRIX keeps track of two things; the amount reserved and the amount in use. When a process wants virtual memory, it has to reserve the amount it wants. If there isn't enough available, then whatever was trying to get the memory gets ENOMEM or the equivalent. But, no space actually gets allocated, until the process wants to page. The number you want is probably the different in the total available and the amount reserved. Again, see . > > >Andrew A. Burgess aab@cichlid.com > -- Alan Rollow alan@nabeth.cxo.dec.com