[BACK]Return to pigs.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / usr.bin / systat

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/usr.bin/systat/pigs.c between version 1.31 and 1.31.6.1

version 1.31, 2009/10/21 21:12:07 version 1.31.6.1, 2013/01/16 05:34:08
Line 48  __RCSID("$NetBSD$");
Line 48  __RCSID("$NetBSD$");
 #include <curses.h>  #include <curses.h>
 #include <math.h>  #include <math.h>
 #include <pwd.h>  #include <pwd.h>
   #include <errno.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
   
Line 60  int compare_pctcpu(const void *, const v
Line 61  int compare_pctcpu(const void *, const v
 int nproc;  int nproc;
 struct p_times *pt;  struct p_times *pt;
   
 u_int64_t stime[CPUSTATES];  uint64_t stime[CPUSTATES];
 long    mempages;  uint64_t mempages;
 int     fscale;  int     fscale;
 double  lccpu;  double  lccpu;
   
Line 140  showpigs(void)
Line 141  showpigs(void)
         wmove(wnd, y, 0); wclrtobot(wnd);          wmove(wnd, y, 0); wclrtobot(wnd);
 }  }
   
 static struct nlist namelist[] = {  
 #define X_FIRST         0  
 #define X_CCPU          0  
         { .n_name = "_ccpu" },  
 #define X_FSCALE        1  
         { .n_name = "_fscale" },  
 #define X_PHYSMEM       2  
         { .n_name = "_physmem" },  
         { .n_name = NULL }  
 };  
   
 int  int
 initpigs(void)  initpigs(void)
 {  {
         fixpt_t ccpu;          fixpt_t ccpu;
           size_t len;
   
         if (namelist[X_FIRST].n_type == 0) {  
                 if (kvm_nlist(kd, namelist)) {  
                         nlisterr(namelist);  
                         return(0);  
                 }  
                 if (namelist[X_FIRST].n_type == 0) {  
                         error("namelist failed");  
                         return(0);  
                 }  
         }  
         (void) fetch_cptime(stime);          (void) fetch_cptime(stime);
         KREAD(NPTR(X_PHYSMEM), &mempages, sizeof (mempages));  
         NREAD(X_CCPU, &ccpu, sizeof ccpu);          len = sizeof(mempages);
         NREAD(X_FSCALE,  &fscale, sizeof fscale);          if (sysctlbyname("hw.physmem64", &mempages, &len, NULL, 0))
                   error("can't get \"hw.physmem64\": %s", strerror(errno));
   
           len = sizeof(ccpu);
           if (sysctlbyname("kern.ccpu", &ccpu, &len, NULL, 0))
                   error("can't get \"kern.ccpu\": %s", strerror(errno));
   
           len = sizeof(fscale);
           if (sysctlbyname("kern.fscale", &fscale, &len, NULL, 0))
                   error("can't get \"kern.fscale\": %s", strerror(errno));
   
         lccpu = log((double) ccpu / fscale);          lccpu = log((double) ccpu / fscale);
   
         return(1);          return(1);
Line 185  fetchpigs(void)
Line 176  fetchpigs(void)
         double t;          double t;
         static int lastnproc = 0;          static int lastnproc = 0;
   
         if (namelist[X_FIRST].n_type == 0)  
                 return;  
         if ((kpp = kvm_getproc2(kd, KERN_PROC_ALL, 0, sizeof(*kpp),          if ((kpp = kvm_getproc2(kd, KERN_PROC_ALL, 0, sizeof(*kpp),
                                 &nproc)) == NULL) {                                  &nproc)) == NULL) {
                 error("%s", kvm_geterr(kd));                  error("%s", kvm_geterr(kd));

Legend:
Removed from v.1.31  
changed lines
  Added in v.1.31.6.1

CVSweb <webmaster@jp.NetBSD.org>