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

Diff for /src/usr.bin/systat/vmstat.c between version 1.94 and 1.95

version 1.94, 2022/02/22 17:35:01 version 1.95, 2022/12/04 18:01:57
Line 98 
Line 98 
 int vm_keyboard_callback(int);  int vm_keyboard_callback(int);
   
 static  time_t t;  static  time_t t;
 static  float hertz;  
 static  int nintr;  static  int nintr;
 static  long *intrloc;  static  long *intrloc;
 static  char **intrname;  static  char **intrname;
Line 170 
Line 169 
         int mib[4], i;          int mib[4], i;
         size_t size;          size_t size;
   
         hertz = stathz;  
         if (!dkinit(1))          if (!dkinit(1))
                 return(0);                  return(0);
   
Line 323 
Line 321 
                 Y(fld); \                  Y(fld); \
                 putint((int)((float)s.fld/etime + 0.5), l, c, w); \                  putint((int)((float)s.fld/etime + 0.5), l, c, w); \
         } while (0)          } while (0)
 #define MAXFAIL 5  
   
 static  char cpuchar[] = { '|', '@', '=', '>', ' ' };  static  char cpuchar[] = { '|', '@', '=', '>', ' ' };
 static  char cpuorder[] = { CP_INTR, CP_SPIN, CP_SYS, CP_USER, CP_IDLE };  static  char cpuorder[] = { CP_INTR, CP_SPIN, CP_SYS, CP_USER, CP_IDLE };
Line 331 
Line 328 
 void  void
 showkre(void)  showkre(void)
 {  {
           static struct timespec prev;
           struct timespec elapsed, now;
         float f1, f2;          float f1, f2;
         int psiz;          int psiz;
         u_int64_t inttotal, intcnt;          u_int64_t inttotal, intcnt;
         int i, l, c;          int i, l, c;
         static int failcnt = 0, first_run = 0;          static int first_run = 0;
         double etime;          double etime;
   
           clock_gettime(CLOCK_UPTIME, &now);
           timespecsub(&now, &prev, &elapsed);
           prev = now;
         if (state == TIME) {          if (state == TIME) {
                 if (!first_run) {                  if (!first_run) {
                         first_run = 1;                          first_run = 1;
                         return;                          return;
                 }                  }
         }          }
         etime = 0;          etime = elapsed.tv_sec + elapsed.tv_nsec / 1000000000.0;
         for (i = 0; i < CPUSTATES; i++) {          for (i = 0; i < CPUSTATES; i++)
                 X(cpustats.cs_time);                  X(cpustats.cs_time);
                 etime += s.cpustats.cs_time[i];  
         }  
         if (etime < 5.0) {      /* < 5 ticks - ignore this trash */  
                 if (failcnt++ >= MAXFAIL) {  
                         error("The alternate system clock has died!");  
                         failcnt = 0;  
                 }  
                 return;  
         }  
         failcnt = 0;  
         etime /= hertz;  
         inttotal = 0;          inttotal = 0;
         for (i = 0; i < nintr; i++) {          for (i = 0; i < nintr; i++) {
                 t = intcnt = s.intrcnt[i];                  t = intcnt = s.intrcnt[i];

Legend:
Removed from v.1.94  
changed lines
  Added in v.1.95