about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-04-11 22:50:35 +0000
committerEric Wong <normalperson@yhbt.net>2013-04-11 22:57:48 +0000
commitd92a3a66adab040ca935c1b3aa0f5965b4cc1d67 (patch)
tree5d2a83dbed0a1f6617fa3ef8b2d53eed7dadb91f
parenta8be099aabc0661e2074e1bd4aa42fbb5139ae0d (diff)
downloadraindrops-d92a3a66adab040ca935c1b3aa0f5965b4cc1d67.tar.gz
The runnable CPUs of a process may change over the lifetime of
the process.  So favor the count of configured processor count
since that is more likely to be stable.

We do not currently do not have special handling for
hot-plugging/removal of CPUs on systems that may load raindrops
in a single CPU state.
-rw-r--r--ext/raindrops/raindrops.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/ext/raindrops/raindrops.c b/ext/raindrops/raindrops.c
index 6cc0d12..65c16e7 100644
--- a/ext/raindrops/raindrops.c
+++ b/ext/raindrops/raindrops.c
@@ -326,11 +326,13 @@ void Init_raindrops_linux_inet_diag(void);
 void Init_raindrops_linux_tcp_info(void);
 #endif
 
-#ifndef _SC_NPROCESSORS_ONLN
-#  ifdef _SC_NPROC_ONLN
-#    define _SC_NPROCESSORS_ONLN _SC_NPROC_ONLN
+#ifndef _SC_NPROCESSORS_CONF
+#  if defined _SC_NPROCESSORS_ONLN
+#    define _SC_NPROCESSORS_CONF _SC_NPROCESSORS_ONLN
+#  elif defined _SC_NPROC_ONLN
+#    define _SC_NPROCESSORS_CONF _SC_NPROC_ONLN
 #  elif defined _SC_CRAY_NCPU
-#    define _SC_NPROCESSORS_ONLN _SC_CRAY_NCPU
+#    define _SC_NPROCESSORS_CONF _SC_CRAY_NCPU
 #  endif
 #endif
 
@@ -359,8 +361,8 @@ void Init_raindrops_ext(void)
         VALUE cRaindrops = rb_define_class("Raindrops", rb_cObject);
         long tmp = 2;
 
-#ifdef _SC_NPROCESSORS_ONLN
-        tmp = sysconf(_SC_NPROCESSORS_ONLN);
+#ifdef _SC_NPROCESSORS_CONF
+        tmp = sysconf(_SC_NPROCESSORS_CONF);
 #endif
         /* no point in padding on single CPU machines */
         if (tmp == 1)