[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.54 and 1.55

version 1.54, 2018/01/04 17:44:20 version 1.55, 2018/09/26 17:23:13
Line 125 
Line 125 
 int  int
 display_resize(void)  display_resize(void)
 {  {
         int display_lines;          int cpu_lines, display_lines, ncpuonline;
         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 + cpu_lines;
         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, ncpuonline;
         double value;          double value;
         int64_t *states;          int64_t *states;
         char **names, *thisname;          char **names, *thisname;
   
           ncpuonline = 0;
           for (i = 0; i < ncpu; i++) {
                   if (online[i])
                           ncpuonline++;
           }
   
         if (combine_cpus) {          if (combine_cpus) {
                 static double *values;                  static double *values;
                 if (!values) {                  if (!values) {
Line 393 
Line 401 
                 }                  }
                 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 419 
                         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 430 
Line 440 
                 first = 0;                  first = 0;
                 states = ostates + (CPUSTATES * cpu);                  states = ostates + (CPUSTATES * cpu);
   
                 if (screen_length > 2 + cpu || !smart_terminal) {                  if ((screen_length > 2 + cpu && 2 + cpu < y_mem) ||
                       !smart_terminal) {
                         move(2 + cpu, 0);                          move(2 + cpu, 0);
                         clrtoeol();                          clrtoeol();
                         addstrp(cpustates_tag(cpu));                          addstrp(cpustates_tag(cpu));
   
                         while ((thisname = *names++) != NULL) {                          while ((thisname = *names++) != NULL) {
                                 if (*thisname != '\0') {                                  if (*thisname != '\0') {
                                           if (!online[cpu]) {
                                                   printwp("%s%5s %s",
                                                       first++ == 0 ? "" : ", ",
                                                       "-", thisname);
                                                   continue;
                                           }
                                         /* retrieve the value and remember it */                                          /* retrieve the value and remember it */
                                         value = *states++;                                          value = *states++;
   

Legend:
Removed from v.1.54  
changed lines
  Added in v.1.55