home *** CD-ROM | disk | FTP | other *** search
- # ifndef lint
- static char SccsId[] = "@(#)percentmem.c 1.1\t10/1/88" ;
- # endif
-
- # include "sps.h"
- # ifndef SUNOS40
- # include <h/text.h>
- # endif
- # ifdef BSD42
- # include <machine/pte.h>
- # else
- # include <h/pte.h>
- # include <h/vmparam.h>
- # endif
- # include <h/vmmac.h>
-
- /* PERCENTMEM - Returns the percentage of real memory used by this process */
- double percentmem ( p )
-
- register struct process *p ;
-
- {
- # ifndef SUNOS40
- register struct text *tp ;
- # endif
- int szptudot ;
- double fracmem ;
- extern struct info Info ;
-
- # ifdef SUNOS40
- if ( !(p->pr_p.p_flag & SLOAD) )
- return ( 0.0 ) ;
- szptudot = UPAGES ;
- fracmem = ( (double)p->pr_p.p_rssize + szptudot ) ;
- # else
- tp = p->pr_p.p_textp ;
- if ( !(p->pr_p.p_flag & SLOAD) || !tp )
- return ( 0.0 ) ;
- szptudot = UPAGES + clrnd( ctopt( p->pr_p.p_dsize + p->pr_p.p_ssize ) );
- fracmem = ( (double)p->pr_p.p_rssize + szptudot ) / CLSIZE ;
- if ( tp->x_ccount )
- fracmem += ((double)tp->x_rssize)/CLSIZE/tp->x_ccount ;
- # endif
- return ( 100.0 * fracmem / (double)Info.i_ecmx ) ;
- }
-