Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* How to check swap space from C
@ 1994-11-21 22:55 Andy Burgess
  1994-11-22  3:02 ` Alan Rollow - Dr. File System's Home for Wayward Inodes.
  1994-11-24  0:37 ` Barry Kort
  0 siblings, 2 replies; 3+ messages in thread
From: Andy Burgess @ 1994-11-21 22:55 UTC (permalink / raw)


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 <stdio.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/swap.h>

#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<n; i++)
          swap_free += table.swt_ent[i].ste_length;

        printf("Swap Free = %dK\n", swap_free);
        exit(0);
}
-------------------------------------------------------------------
Thanks very much for any information you can provide.
Andy

-- 
Andrew A. Burgess                                    aab@cichlid.com
Free UUCP email/newsfeeds, Santa Cruz CA area, mail info@cichlid.com


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

* Re: How to check swap space from C
  1994-11-21 22:55 How to check swap space from C Andy Burgess
@ 1994-11-22  3:02 ` Alan Rollow - Dr. File System's Home for Wayward Inodes.
  1994-11-24  0:37 ` Barry Kort
  1 sibling, 0 replies; 3+ messages in thread
From: Alan Rollow - Dr. File System's Home for Wayward Inodes. @ 1994-11-22  3:02 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1213 bytes --]


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 <sys/dmap.h>.
    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 <sys/dmap.h>.
>
>
>Andrew A. Burgess                                    aab@cichlid.com
>
--
Alan Rollow				alan@nabeth.cxo.dec.com



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

* Re: How to check swap space from C
  1994-11-21 22:55 How to check swap space from C Andy Burgess
  1994-11-22  3:02 ` Alan Rollow - Dr. File System's Home for Wayward Inodes.
@ 1994-11-24  0:37 ` Barry Kort
  1 sibling, 0 replies; 3+ messages in thread
From: Barry Kort @ 1994-11-24  0:37 UTC (permalink / raw)


Andy Burgess (aab@cichlid.com) wrote:
: 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

In Ultrix, the command /etc/pstat -s will return this information,
so you could always do a system call to the Ultrix shell and run
that command.  --Barry Kort


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

end of thread, other threads:[~1994-11-24  0:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-11-21 22:55 How to check swap space from C Andy Burgess
1994-11-22  3:02 ` Alan Rollow - Dr. File System's Home for Wayward Inodes.
1994-11-24  0:37 ` Barry Kort

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