Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: aab@cichlid.com (Andy Burgess)
Subject: How to check swap space from C
Date: 21 Nov 1994 14:55:44 -0800	[thread overview]
Message-ID: <3ar8hg$ov6@loach.cichlid.com> (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


             reply	other threads:[~1994-11-21 22:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-11-21 22:55 Andy Burgess [this message]
1994-11-22  3:02 ` How to check swap space from C Alan Rollow - Dr. File System's Home for Wayward Inodes.
1994-11-24  0:37 ` Barry Kort
read-only archive

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