#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
+#include <string.h>
#include <errno.h>
#include "cpu-top.h"
+int cpu_top_init(struct cpu_top *cpu)
+{
+ memset(cpu, 0, sizeof(*cpu));
+
+ cpu->nr_cpu = sysconf(_SC_NPROCESSORS_ONLN);
+
+ return 0;
+}
+
int cpu_top_update(struct cpu_top *cpu)
{
struct cpu_stat *s = &cpu->stat[cpu->count++&1];
};
int n;
+ cpu_top_init(>->cpu_top);
gpu_top_init(>->gpu_top);
- memset(>->cpu, 0, sizeof(gt->cpu));
chart_init(>->cpu, "CPU", 120);
chart_set_position(>->cpu, PAD, PAD);
y = PAD + 12 - 2;
cairo_set_source_rgba(ctx->cr, 0.75, 0.25, 0.75, 1.);
cairo_move_to(ctx->cr, PAD, y);
- sprintf(txt, "CPU: %3d%% busy", gt->cpu_top.busy);
+ sprintf(txt, "CPU: %3d%% busy", gt->cpu_top.busy * gt->cpu_top.nr_cpu);
cairo_show_text(ctx->cr, txt);
y += 14;