version 1.54, 2018/01/04 17:44:20 |
version 1.55, 2018/09/26 17:23:13 |
|
|
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; |
|
|
/* 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; |
|
|
|
|
} |
} |
|
|
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) { |
|
|
} |
} |
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; |
|
|
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 ? "" : ", ", |
|
|
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++; |
|
|