Enlightenment CVS committal

Author  : handyande
Project : e17
Module  : apps/e_modules

Dir     : e17/apps/e_modules/src/modules/monitor


Modified Files:
        linux_2.6.c 


Log Message:
SMP support (rather hackish, but it works(tm)), just got fed up of the 200% on 
my machine
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/apps/e_modules/src/modules/monitor/linux_2.6.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- linux_2.6.c 22 May 2005 03:07:06 -0000      1.1
+++ linux_2.6.c 30 May 2005 16:07:43 -0000      1.2
@@ -1,6 +1,28 @@
 
 #include "linux_2.6.h"
 
+static int __monitor_cpu_count = -1;
+
+int
+count_cpus(void)
+{
+  char tmp[4];
+  FILE     *stat;
+  int       cpu = -1;
+       
+  if ( !(stat = fopen ("/proc/stat", "r")) )
+    return -1;
+
+  while (fscanf (stat, "cp%s %*lu %*lu %*lu %*lu %*lu %*lu %*lu %*lu\n", &tmp) 
== 1)
+    {
+       cpu++;
+    }
+  fclose (stat);
+
+  __monitor_cpu_count = cpu;
+  return cpu;
+}
+
 int
 four_cpu_numbers(int *uret, int *nret, int *sret, int *iret)
 {
@@ -65,10 +87,11 @@
 
   if ( four_cpu_numbers( &u, &n, &s, &i ) == -1 )
     return -1;
+  if (__monitor_cpu_count == -1)
+    count_cpus();
 
   load = u + n + s;
-
-  return load;
+  return load / __monitor_cpu_count;
 }
 
 char *net_dev = "eth0";




-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to