[BACK]Return to machine.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / top

Diff for /src/usr.bin/top/machine.c between version 1.65 and 1.66

version 1.65, 2010/01/29 00:36:09 version 1.66, 2010/03/26 05:10:50
Line 87 
Line 87 
         "", "start", "run", "sleep", "stop", "zomb", "dead", "onproc"          "", "start", "run", "sleep", "stop", "zomb", "dead", "onproc"
 };  };
   
 static int      stathz;  
   
 /* these are for calculating cpu state percentages */  /* these are for calculating cpu state percentages */
 static int64_t     **cp_time;  static int64_t     **cp_time;
 static int64_t     **cp_old;  static int64_t     **cp_old;
Line 138 
Line 136 
   
 unsigned int    maxslp;  unsigned int    maxslp;
   
 static int  
 getstathz(void)  
 {  
         struct clockinfo cinf;  
         size_t size = sizeof(cinf);  
         int mib[2];  
   
         mib[0] = CTL_KERN;  
         mib[1] = KERN_CLOCKRATE;  
         if (sysctl(mib, 2, &cinf, &size, NULL, 0) == -1)  
                 return (-1);  
         return (cinf.stathz);  
 }  
   
 int  int
 machine_init(struct statics *statics)  machine_init(struct statics *statics)
 {  {
Line 179 
Line 163 
                         err(1, NULL);                          err(1, NULL);
         }          }
   
         stathz = getstathz();  
         if (stathz == -1)  
                 return (-1);  
   
         pbase = NULL;          pbase = NULL;
         pref = NULL;          pref = NULL;
         onproc = -1;          onproc = -1;
Line 471 
Line 451 
         pp = *(hp->next_proc++);          pp = *(hp->next_proc++);
         hp->remaining--;          hp->remaining--;
   
         cputime = (pp->p_uticks + pp->p_sticks + pp->p_iticks) / stathz;          cputime = pp->p_rtime_sec + ((pp->p_rtime_usec + 500000) / 1000000);
   
         /* calculate the base for cpu percentages */          /* calculate the base for cpu percentages */
         pct = pctdouble(pp->p_pctcpu);          pct = pctdouble(pp->p_pctcpu);

Legend:
Removed from v.1.65  
changed lines
  Added in v.1.66