smp support, should be the last commit (yeah right!)
authorBrenden Matthews <brenden1@rty.ca>
Sat, 27 Aug 2005 10:17:41 +0000 (10:17 +0000)
committerBrenden Matthews <brenden1@rty.ca>
Sat, 27 Aug 2005 10:17:41 +0000 (10:17 +0000)
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@212 7f574dfc-610e-0410-a909-a81674777703

ChangeLog
doc/variables.xml
src/linux.c

index d1ed466..4c6e42a 100644 (file)
--- 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
index 5c424c9..48cf732 100644 (file)
 <varlistentry>
        <term>
                <command><option>cpu</option></command>
+               <option>(cpu number)</option>
        </term>
        <listitem>
-               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.
        <para></para></listitem>
 </varlistentry>
 
 <varlistentry>
        <term>
                <command><option>cpubar</option></command>
-       <option>(height),(width)</option>
+               <option>(cpu number) (height),(width)</option>
        </term>
        <listitem>
                Bar that shows CPU usage, height is bar's height in pixels
 <varlistentry>
        <term>
                <command><option>cpugraph</option></command>
-       <option>(height),(width) (gradient colour 1) (gradient colour 2)</option>
+       <option>(cpu number) (height),(width) (gradient colour 1) (gradient colour 2)</option>
        </term>
        <listitem>
-               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.
        <para></para></listitem>
 </varlistentry>
 
index a383cd4..6a3a1ff 100644 (file)
@@ -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) {