diff options
author | Jennifer Averett <jennifer.averett@oarcorp.com> | 2014-01-31 08:54:45 -0600 |
---|---|---|
committer | Jennifer Averett <jennifer.averett@oarcorp.com> | 2014-03-07 09:10:33 -0600 |
commit | 185e46f6a05295755f0f4522cf44c93ec8cbd7d1 (patch) | |
tree | 05571a7fb077cf768913b7403a834baee89ab07c /cpukit/posix/src/pthreadcreate.c | |
parent | rtems: Add Classic API get and set affinity methods. (diff) | |
download | rtems-185e46f6a05295755f0f4522cf44c93ec8cbd7d1.tar.bz2 |
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.
Diffstat (limited to 'cpukit/posix/src/pthreadcreate.c')
-rw-r--r-- | cpukit/posix/src/pthreadcreate.c | 19 |
1 files changed, 17 insertions, 2 deletions
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 <rtems/posix/priorityimpl.h> #include <rtems/posix/pthreadimpl.h> #include <rtems/posix/time.h> +#include <rtems/score/cpusetimpl.h> #include <rtems/score/threadimpl.h> #include <rtems/score/apimutex.h> #include <rtems/score/stackimpl.h> @@ -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; |