diff options
Diffstat (limited to 'cpukit/posix/src/pthreadgetaffinitynp.c')
-rw-r--r-- | cpukit/posix/src/pthreadgetaffinitynp.c | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/cpukit/posix/src/pthreadgetaffinitynp.c b/cpukit/posix/src/pthreadgetaffinitynp.c index 76369546c2..7e0c32e03c 100644 --- a/cpukit/posix/src/pthreadgetaffinitynp.c +++ b/cpukit/posix/src/pthreadgetaffinitynp.c @@ -31,37 +31,38 @@ #include <rtems/score/schedulerimpl.h> int pthread_getaffinity_np( - const pthread_t id, - size_t cpusetsize, - cpu_set_t *cpuset + pthread_t thread, + size_t cpusetsize, + cpu_set_t *cpuset ) { - Objects_Locations location; - Thread_Control *the_thread; - bool ok; + Thread_Control *the_thread; + ISR_lock_Context lock_context; + Per_CPU_Control *cpu_self; + bool ok; - if ( !cpuset ) + if ( cpuset == NULL ) { return EFAULT; + } - the_thread = _Thread_Get( id, &location ); - switch ( location ) { - - case OBJECTS_LOCAL: - ok = _Scheduler_Get_affinity( - the_thread, - cpusetsize, - cpuset - ); - _Objects_Put( &the_thread->Object ); - return ok ? 0 : EINVAL; + the_thread = _Thread_Get_interrupt_disable( thread, &lock_context ); -#if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: -#endif - case OBJECTS_ERROR: - break; + if ( the_thread == NULL ) { + return ESRCH; } - return ESRCH; + + cpu_self = _Thread_Dispatch_disable_critical( &lock_context ); + _Thread_State_acquire_critical( the_thread, &lock_context ); + + ok = _Scheduler_Get_affinity( + the_thread, + cpusetsize, + cpuset + ); + + _Thread_State_release( the_thread, &lock_context ); + _Thread_Dispatch_enable( cpu_self ); + return ok ? 0 : EINVAL; } #endif |