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/rtems | |
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/rtems')
-rw-r--r-- | cpukit/rtems/src/taskgetaffinity.c | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/cpukit/rtems/src/taskgetaffinity.c b/cpukit/rtems/src/taskgetaffinity.c index 25339b4e47..27c21db80b 100644 --- a/cpukit/rtems/src/taskgetaffinity.c +++ b/cpukit/rtems/src/taskgetaffinity.c @@ -25,41 +25,44 @@ #include <rtems/score/cpusetimpl.h> #include <rtems/score/schedulerimpl.h> - rtems_status_code rtems_task_get_affinity( - rtems_id id, - size_t cpusetsize, - cpu_set_t *cpuset + rtems_id id, + size_t cpusetsize, + cpu_set_t *cpuset ) { - Thread_Control *the_thread; - Objects_Locations location; - bool ok; + Thread_Control *the_thread; + ISR_lock_Context lock_context; + Per_CPU_Control *cpu_self; + bool ok; - if ( !cpuset ) + if ( cpuset == NULL ) { return RTEMS_INVALID_ADDRESS; + } - 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 ? RTEMS_SUCCESSFUL : RTEMS_INVALID_NUMBER; + the_thread = _Thread_Get_interrupt_disable( id, &lock_context ); + if ( the_thread == NULL ) { #if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: + if ( _Thread_MP_Is_remote( id ) ) { + return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; + } #endif - case OBJECTS_ERROR: - break; + return RTEMS_INVALID_ID; } - return RTEMS_INVALID_ID; + 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 ? RTEMS_SUCCESSFUL : RTEMS_INVALID_NUMBER; } #endif |