summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormonsta <[email protected]>2016-02-10 14:07:57 +0300
committermonsta <[email protected]>2016-02-10 14:07:57 +0300
commitdb4046a313255440eb8432680aa4c920a7813c98 (patch)
tree4f90d1ea312d50af9eaba9b8e1d2bdd00e103069
parent107d04fdbf5b22b439b13a648353974157cca6a3 (diff)
downloadmate-system-monitor-db4046a313255440eb8432680aa4c920a7813c98.tar.bz2
mate-system-monitor-db4046a313255440eb8432680aa4c920a7813c98.tar.xz
get exact number of CPUs instead of guessing
adapted from https://git.gnome.org/browse/gnome-system-monitor/commit/?id=549e2e3308620810dd795321d02f041e8ab58d29
-rw-r--r--src/procman.cpp15
1 files 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 <bacon-message-connection.h>
#include <glibtop.h>
#include <glibtop/close.h>
+#include <glibtop/cpu.h>
+#include <glibtop/sysinfo.h>
#include <glibtop/loadavg.h>
#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++) {