diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-11 11:06:51 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-12 13:24:41 +0200 |
commit | d99529999451043166c6dbf3ef22be42463e16f3 (patch) | |
tree | 4e773a423ceca724db1c58a64345583745169027 /cpukit/posix/src | |
parent | score: Avoid Giant lock _Scheduler_Set_affinity() (diff) | |
download | rtems-d99529999451043166c6dbf3ef22be42463e16f3.tar.bz2 |
score: Avoid Giant lock _Scheduler_Get_affinity()
Update #2555.
Diffstat (limited to 'cpukit/posix/src')
-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 |