home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume3 / sps / part2 / percentmem.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-11-30  |  823 b   |  31 lines

  1. # include       "sps.h"
  2. # include       <h/text.h>
  3. # ifdef BSD42
  4. # include    <machine/pte.h>
  5. # else
  6. # include       <h/pte.h>
  7. # include       <h/vmparam.h>
  8. # endif
  9. # include       <h/vmmac.h>
  10.  
  11. /* PERCENTMEM - Returns the percentage of real memory used by this process */
  12. double  percentmem ( p )
  13.  
  14. register struct process         *p ;
  15.  
  16. {
  17.     register struct text    *tp ;
  18.     int                     szptudot ;
  19.     double                  fracmem ;
  20.     extern struct info      Info ;
  21.  
  22.     tp = p->pr_p.p_textp ;
  23.     if ( !(p->pr_p.p_flag & SLOAD) || !tp )
  24.         return ( 0.0 ) ;
  25.     szptudot = UPAGES + clrnd( ctopt( p->pr_p.p_dsize + p->pr_p.p_ssize ) );
  26.     fracmem = ( (double)p->pr_p.p_rssize + szptudot ) / CLSIZE ;
  27.     if ( tp->x_ccount )
  28.         fracmem += ((double)tp->x_rssize)/CLSIZE/tp->x_ccount ;
  29.     return ( 100.0 * fracmem / (double)Info.i_ecmx ) ;
  30. }
  31.