summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--overlay/cpu-top.c10
-rw-r--r--overlay/cpu-top.h2
-rw-r--r--overlay/overlay.c4
3 files changed, 14 insertions, 2 deletions
diff --git a/overlay/cpu-top.c b/overlay/cpu-top.c
index 4e31da1b..c134d409 100644
--- a/overlay/cpu-top.c
+++ b/overlay/cpu-top.c
@@ -25,10 +25,20 @@
#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];
diff --git a/overlay/cpu-top.h b/overlay/cpu-top.h
index 8d630fd9..c91814fd 100644
--- a/overlay/cpu-top.h
+++ b/overlay/cpu-top.h
@@ -29,6 +29,7 @@
struct cpu_top {
uint8_t busy;
+ int nr_cpu;
int count;
struct cpu_stat {
@@ -37,6 +38,7 @@ struct cpu_top {
} stat[2];
};
+int cpu_top_init(struct cpu_top *cpu);
int cpu_top_update(struct cpu_top *cpu);
#endif /* CPU_TOP_H */
diff --git a/overlay/overlay.c b/overlay/overlay.c
index 08b90aef..a457a409 100644
--- a/overlay/overlay.c
+++ b/overlay/overlay.c
@@ -143,8 +143,8 @@ static void init_gpu_top(struct overlay_context *ctx,
};
int n;
+ cpu_top_init(&gt->cpu_top);
gpu_top_init(&gt->gpu_top);
- memset(&gt->cpu, 0, sizeof(gt->cpu));
chart_init(&gt->cpu, "CPU", 120);
chart_set_position(&gt->cpu, PAD, PAD);
@@ -222,7 +222,7 @@ static void show_gpu_top(struct overlay_context *ctx, struct overlay_gpu_top *gt
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;