[PATCH 06/10] posix: Modified pthread init to use cpuset default.

Jennifer jennifer.averett at oarcorp.com
Mon Mar 24 18:39:37 UTC 2014


From: Jennifer Averett <jennifer.averett at oarcorp.com>

---
 cpukit/posix/src/pthread.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/cpukit/posix/src/pthread.c b/cpukit/posix/src/pthread.c
index 7968f17..41115ff 100644
--- a/cpukit/posix/src/pthread.c
+++ b/cpukit/posix/src/pthread.c
@@ -41,6 +41,8 @@
 #include <rtems/posix/keyimpl.h>
 #include <rtems/posix/time.h>
 #include <rtems/score/timespec.h>
+#include <rtems/score/cpusetimpl.h>
+#include <rtems/score/assert.h>
 
 /*
  *  The default pthreads attributes structure.
@@ -348,24 +350,18 @@ User_extensions_Control _POSIX_Threads_User_extensions = {
 void _POSIX_Threads_Manager_initialization(void)
 {
   #if defined(__RTEMS_HAVE_SYS_CPUSET_H__)
+    const CPU_set_Control *affinity;
     pthread_attr_t *attr;
-    int i;
-    int max_cpus = 1;
 
     /* Initialize default attribute. */
     attr = &_POSIX_Threads_Default_attributes;
 
-    /* We do not support a cpu count over CPU_SETSIZE  */
-    max_cpus = _SMP_Get_processor_count();
-    assert( max_cpus <= CPU_SETSIZE );
-
-    /*  Initialize the affinity to be the set of all available CPU's   */
+    /*  Initialize the affinity to be the default cpu set for the system */
+    affinity = _CPU_set_Default();
+    _Assert( affinity->setsize == sizeof( attr->affinitysetpreallocated ) );
     attr->affinityset             = &attr->affinitysetpreallocated;
-    attr->affinitysetsize         = sizeof( *attr->affinityset );
-    CPU_ZERO_S( attr->affinitysetsize, &attr->affinitysetpreallocated );
-
-    for (i=0; i<max_cpus; i++)
-      CPU_SET_S(i, attr->affinitysetsize, attr->affinityset );
+    attr->affinitysetsize         = affinity->setsize;
+    CPU_COPY( attr->affinityset, affinity->set );
   #endif
 
   _Objects_Initialize_information(
-- 
1.8.1.4




More information about the devel mailing list