From db4046a313255440eb8432680aa4c920a7813c98 Mon Sep 17 00:00:00 2001 From: monsta Date: Wed, 10 Feb 2016 14:07:57 +0300 Subject: get exact number of CPUs instead of guessing adapted from https://git.gnome.org/browse/gnome-system-monitor/commit/?id=549e2e3308620810dd795321d02f041e8ab58d29 --- src/procman.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/procman.cpp b/src/procman.cpp index a21df0e..7f851cb 100644 --- a/src/procman.cpp +++ b/src/procman.cpp @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include #include "load-graph.h" @@ -239,12 +241,10 @@ show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data) static ProcData * procman_data_new (GSettings *settings) { - ProcData *pd; gchar *color; gchar **keys; gint swidth, sheight; - gint i; glibtop_cpu cpu; pd = ProcData::get_instance(); @@ -285,17 +285,10 @@ procman_data_new (GSettings *settings) g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd); pd->config.current_tab = g_settings_get_int (settings, "current-tab"); - /* Determinie number of cpus since libgtop doesn't really tell you*/ - pd->config.num_cpus = 0; glibtop_get_cpu (&cpu); pd->frequency = cpu.frequency; - i=0; - while (i < GLIBTOP_NCPU && cpu.xcpu_total[i] != 0) { - pd->config.num_cpus ++; - i++; - } - if (pd->config.num_cpus == 0) - pd->config.num_cpus = 1; + + pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1 keys = g_settings_list_keys (settings); for (int i = 0; i < pd->config.num_cpus; i++) { -- cgit v1.2.1