From 185e46f6a05295755f0f4522cf44c93ec8cbd7d1 Mon Sep 17 00:00:00 2001 From: Jennifer Averett Date: Fri, 31 Jan 2014 08:54:45 -0600 Subject: posix: Add POSIX thread affinity attribute support. With the addition of pthread affinity information in pthread_attr_t, the existing code for pthread_attr_t had to be adjusted. --- cpukit/posix/src/pthreadcreate.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'cpukit/posix/src/pthreadcreate.c') diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c index b780eccfe9..b1483726e0 100644 --- a/cpukit/posix/src/pthreadcreate.c +++ b/cpukit/posix/src/pthreadcreate.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -136,6 +137,14 @@ int pthread_create( if ( rc ) return rc; +#if defined(RTEMS_SMP) +#if __RTEMS_HAVE_SYS_CPUSET_H__ + rc = _CPU_set_Is_valid( attr->affinityset, attr->affinitysetsize ); + if ( rc != 0 ) + return EINVAL; +#endif +#endif + /* * Currently all POSIX threads are floating point if the hardware * supports it. @@ -179,19 +188,25 @@ int pthread_create( 0, /* isr level */ name /* posix threads don't have a name */ ); - if ( !status ) { _POSIX_Threads_Free( the_thread ); _RTEMS_Unlock_allocator(); return EAGAIN; } +#if defined(RTEMS_SMP) +#if __RTEMS_HAVE_SYS_CPUSET_H__ + the_thread->affinity.setsize = attr->affinitysetsize; + *the_thread->affinity.set = *attr->affinityset; +#endif +#endif + /* * finish initializing the per API structure */ api = the_thread->API_Extensions[ THREAD_API_POSIX ]; - api->Attributes = *the_attr; + _POSIX_Threads_Copy_attributes( &api->Attributes, the_attr ); api->detachstate = the_attr->detachstate; api->schedpolicy = schedpolicy; api->schedparam = schedparam; -- cgit v1.2.3