Bug #2447 » 0001-refs-2447-TOP-isn-t-reporting-correctly-CPU-states-w.patch
usr.bin/top/m_dragonfly.c | ||
---|---|---|
/* these are for detailing the cpu states */
|
||
#define CPU_STATES 5
|
||
int *cpu_states;
|
||
int* cpu_averages;
|
||
char *cpustatenames[CPU_STATES + 1] = {
|
||
"user", "nice", "system", "interrupt", "idle", NULL
|
||
};
|
||
... | ... | |
lastpid = 0;
|
||
/* convert cp_time counts to percentages */
|
||
int combine_cpus = (enable_ncpus == 0 && n_cpus > 1);
|
||
for (cpu = 0; cpu < n_cpus; ++cpu) {
|
||
cputime_percentages(cpu_states + cpu * CPU_STATES,
|
||
&cp_time[cpu], &cp_old[cpu]);
|
||
}
|
||
if (combine_cpus) {
|
||
if (cpu_averages == NULL) {
|
||
cpu_averages = calloc(CPU_STATES, sizeof(*cpu_averages));
|
||
if (cpu_averages == NULL)
|
||
err(1, "cpu_averages");
|
||
}
|
||
memset(cpu_averages, 0, sizeof(*cpu_averages) * CPU_STATES);
|
||
for (cpu = 0; cpu < n_cpus; ++cpu) {
|
||
int j = 0;
|
||
cpu_averages[0] += *(cpu_states + ((cpu * CPU_STATES) + j++) );
|
||
cpu_averages[1] += *(cpu_states + ((cpu * CPU_STATES) + j++) );
|
||
cpu_averages[2] += *(cpu_states + ((cpu * CPU_STATES) + j++) );
|
||
cpu_averages[3] += *(cpu_states + ((cpu * CPU_STATES) + j++) );
|
||
cpu_averages[4] += *(cpu_states + ((cpu * CPU_STATES) + j++) );
|
||
}
|
||
for (int i = 0; i < CPU_STATES; ++i)
|
||
cpu_averages[i] /= n_cpus;
|
||
}
|
||
/* sum memory & swap statistics */
|
||
{
|
||
... | ... | |
}
|
||
/* set arrays and strings */
|
||
si->cpustates = cpu_states;
|
||
si->cpustates = combine_cpus == 1 ?
|
||
cpu_averages : cpu_states;
|
||
si->memory = memory_stats;
|
||
si->swap = swap_stats;
|
||
usr.bin/top/top.1 | ||
---|---|---|
by a breakdown of processes per state. Examples of states common
|
||
to Unix systems are sleeping, running, starting, stopped, and zombie.
|
||
The next line displays a percentage of time spent in each of the
|
||
processor states (typically user, nice, system, idle, and iowait).
|
||
processor states (user, nice, system, interrupt, idle).
|
||
These percentages show the processor activity during the time since
|
||
the last update. For multi-processor systems, this information is
|
||
a summation of time across all processors. The next line shows
|
||
an average of all processors. The next line shows
|
||
kernel-related activity (not available on all systems). The numbers
|
||
shown on this line are per-second rates sampled since the last update.
|
||
The exact
|
- « Previous
- 1
- 2
- Next »