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

Diff for /src/usr.bin/top/display.c between version 1.56 and 1.57

version 1.56, 2018/10/05 18:56:57 version 1.57, 2018/11/17 23:10:08
Line 100 
Line 100 
 int y_idlecursor;  int y_idlecursor;
 int y_procs;  int y_procs;
 extern int ncpu;  extern int ncpu;
   extern int ncpuonline;
 extern int combine_cpus;  extern int combine_cpus;
 extern struct process_select ps;  extern struct process_select ps;
   
Line 125 
Line 126 
 int  int
 display_resize(void)  display_resize(void)
 {  {
         int display_lines;          int cpu_lines, display_lines;
         int cpu_lines = (combine_cpus ? 1 : ncpu);  
   
           ncpuonline = getncpuonline();
           cpu_lines = (combine_cpus ? 1 : ncpuonline);
         y_mem = 2 + cpu_lines;          y_mem = 2 + cpu_lines;
         y_header = 4 + cpu_lines;          y_header = 4 + cpu_lines;
         y_procs = 5 + cpu_lines;          y_procs = 5 + cpu_lines;
Line 136 
Line 138 
         /* if operating in "dumb" mode, we only need one line */          /* if operating in "dumb" mode, we only need one line */
         display_lines = smart_terminal ? screen_length - y_procs : 1;          display_lines = smart_terminal ? screen_length - y_procs : 1;
   
         y_idlecursor = y_message = 3 + (combine_cpus ? 1 : ncpu);          y_idlecursor = y_message = 3 + (combine_cpus ? 1 : ncpuonline);
         if (screen_length <= y_message)          if (screen_length <= y_message)
                 y_idlecursor = y_message = screen_length - 1;                  y_idlecursor = y_message = screen_length - 1;
   
Line 377 
Line 379 
 }  }
   
 void  void
 i_cpustates(int64_t *ostates)  i_cpustates(int64_t *ostates, int *online)
 {  {
         int i, first, cpu;          int i, first, cpu, cpu_line;
         double value;          double value;
         int64_t *states;          int64_t *states;
         char **names, *thisname;          char **names, *thisname;
Line 393 
Line 395 
                 }                  }
                 memset(values, 0, num_cpustates * sizeof(*values));                  memset(values, 0, num_cpustates * sizeof(*values));
                 for (cpu = 0; cpu < ncpu; cpu++) {                  for (cpu = 0; cpu < ncpu; cpu++) {
                           if (!online[cpu])
                                   continue;
                         names = cpustate_names;                          names = cpustate_names;
                         states = ostates + (CPUSTATES * cpu);                          states = ostates + (CPUSTATES * cpu);
                         i = 0;                          i = 0;
Line 409 
Line 413 
                         first = 0;                          first = 0;
                         move(2, 0);                          move(2, 0);
                         clrtoeol();                          clrtoeol();
                         printwp("%-3d CPUs: ", ncpu);                          printwp("%-3d CPUs: ", ncpuonline);
   
                         while ((thisname = *names++) != NULL) {                          while ((thisname = *names++) != NULL) {
                                 if (*thisname != '\0') {                                  if (*thisname != '\0') {
                                         value = values[i++] / ncpu;                                          value = values[i++] / ncpuonline;
                                         /* if percentage is >= 1000, print it as 100% */                                          /* if percentage is >= 1000, print it as 100% */
                                         printwp((value >= 1000 ? "%s%4.0f%% %s" :                                          printwp((value >= 1000 ? "%s%4.0f%% %s" :
                                             "%s%4.1f%% %s"), first++ == 0 ? "" : ", ",                                              "%s%4.1f%% %s"), first++ == 0 ? "" : ", ",
Line 424 
Line 428 
                 }                  }
                 return;                  return;
         }          }
         for (cpu = 0; cpu < ncpu; cpu++) {          for (cpu = cpu_line = 0; cpu < ncpu; cpu++) {
                   /* skip if offline */
                   if (!online[cpu])
                           continue;
   
                 /* now walk thru the names and print the line */                  /* now walk thru the names and print the line */
                 names = cpustate_names;                  names = cpustate_names;
                 first = 0;                  first = 0;
                 states = ostates + (CPUSTATES * cpu);                  states = ostates + (CPUSTATES * cpu);
   
                 if (screen_length > 2 + cpu || !smart_terminal) {                  if (screen_length > 2 + cpu_line || !smart_terminal) {
                         move(2 + cpu, 0);                          move(2 + cpu_line, 0);
                         clrtoeol();                          clrtoeol();
                         addstrp(cpustates_tag(cpu));                          addstrp(cpustates_tag(cpu));
   
Line 447 
Line 455 
                                 }                                  }
                         }                          }
                         putn();                          putn();
                           cpu_line++;
                 }                  }
         }          }
 }  }

Legend:
Removed from v.1.56  
changed lines
  Added in v.1.57