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

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