diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-11 13:42:58 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-12 13:24:41 +0200 |
commit | 8bc6bf28aa098a03c25763e3c59274874bfbe3da (patch) | |
tree | c7b1434c02d96b48cba14c3bcfeb2c865c4f816f /cpukit/posix/src/pthreadgetattrnp.c | |
parent | score: Avoid Giant lock _Scheduler_Get_affinity() (diff) | |
download | rtems-8bc6bf28aa098a03c25763e3c59274874bfbe3da.tar.bz2 |
posix: Avoid Giant lock for some pthread functions
Avoid Giant lock for pthread_getattr_np(), pthread_setschedparam() and
pthread_getschedparam(). Replace POSIX threads scheduler lock with
thread state lock.
Update #2555.
Diffstat (limited to 'cpukit/posix/src/pthreadgetattrnp.c')
-rw-r--r-- | cpukit/posix/src/pthreadgetattrnp.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/cpukit/posix/src/pthreadgetattrnp.c b/cpukit/posix/src/pthreadgetattrnp.c index f71819f998..57c53183ed 100644 --- a/cpukit/posix/src/pthreadgetattrnp.c +++ b/cpukit/posix/src/pthreadgetattrnp.c @@ -26,32 +26,29 @@ #include <rtems/score/threadimpl.h> int pthread_getattr_np( - pthread_t id, + pthread_t thread, pthread_attr_t *attr ) { - Objects_Locations location; - POSIX_API_Control *api; - Thread_Control *the_thread; + Thread_Control *the_thread; + ISR_lock_Context lock_context; + POSIX_API_Control *api; - if ( !attr ) + if ( attr == NULL ) { return EINVAL; + } - the_thread = _Thread_Get( id, &location ); - switch ( location ) { - - case OBJECTS_LOCAL: - api = the_thread->API_Extensions[ THREAD_API_POSIX ]; - _POSIX_Threads_Copy_attributes( attr, &api->Attributes); - _Objects_Put( &the_thread->Object ); - return 0; + 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; + _Thread_State_acquire_critical( the_thread, &lock_context ); + + api = the_thread->API_Extensions[ THREAD_API_POSIX ]; + _POSIX_Threads_Copy_attributes( attr, &api->Attributes); + + _Thread_State_release( the_thread, &lock_context ); + return 0; } |