From e93155d26b746d29ca200d11216d20cd6de3e591 Mon Sep 17 00:00:00 2001 From: Brenden Matthews Date: Sat, 27 Aug 2005 10:17:41 +0000 Subject: [PATCH] smp support, should be the last commit (yeah right!) git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@212 7f574dfc-610e-0410-a909-a81674777703 --- ChangeLog | 1 + doc/variables.xml | 9 +++++---- src/linux.c | 10 +++------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index d1ed4669..4c6e42ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ * Fixed slight vertical misalignment of bars/graphs (sf.net 1273994) * Diskio fixes (sf.net 1274140) * $alignr and $alignc now have 25% more goodness! (sf.net bug 1273905) + * Far better SMP support 2005-08-25 * More own_window fixes diff --git a/doc/variables.xml b/doc/variables.xml index 5c424c9a..48cf732b 100644 --- a/doc/variables.xml +++ b/doc/variables.xml @@ -124,16 +124,17 @@ + - CPU usage in percents + CPU usage in percents. For SMP machines, the CPU number can be provided as an argument. 0 is the total usage, and >=1 are individual CPUs. See $cpu for more info on SMP. - + Bar that shows CPU usage, height is bar's height in pixels @@ -143,10 +144,10 @@ - + - CPU usage graph, with optional colours in hex, minus the #. + CPU usage graph, with optional colours in hex, minus the #. See $cpu for more info on SMP. diff --git a/src/linux.c b/src/linux.c index a383cd49..6a3a1ff2 100644 --- a/src/linux.c +++ b/src/linux.c @@ -370,11 +370,7 @@ inline static void update_stat() cpu_setup = 1; } if (cpu == NULL) { - if (info.cpu_count > 1) { - cpu = malloc((info.cpu_count + 1) * sizeof(struct cpu_info)); - } else { - cpu = malloc(info.cpu_count * sizeof(struct cpu_info)); - } + cpu = malloc((info.cpu_count + 1) * sizeof(struct cpu_info)); } if (stat_fp == NULL) { stat_fp = open_file("/proc/stat", &rep); @@ -396,13 +392,13 @@ inline static void update_stat() sscanf(buf, "%*s %u %u %u", &(cpu[index].cpu_user), &(cpu[index].cpu_nice), &(cpu[index].cpu_system)); index++; info.mask |= (1 << INFO_CPU); - } else if (strncmp(buf, "cpu", 3) == 0 && isdigit(buf[3]) && index < info.cpu_count) { + } else if (strncmp(buf, "cpu", 3) == 0 && isdigit(buf[3]) && index <= info.cpu_count) { sscanf(buf, "%*s %u %u %u", &(cpu[index].cpu_user), &(cpu[index].cpu_nice), &(cpu[index].cpu_system)); index++; info.mask |= (1 << INFO_CPU); } } - for (index = 0; index < info.cpu_count; index++) { + for (index = 0; index < info.cpu_count + 1; index++) { double delta; delta = current_update_time - last_update_time; if (delta <= 0.001) {