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/pthreadgetschedparam.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/pthreadgetschedparam.c')
-rw-r--r-- | cpukit/posix/src/pthreadgetschedparam.c | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/cpukit/posix/src/pthreadgetschedparam.c b/cpukit/posix/src/pthreadgetschedparam.c index d3fa9d430a..d769d8a520 100644 --- a/cpukit/posix/src/pthreadgetschedparam.c +++ b/cpukit/posix/src/pthreadgetschedparam.c @@ -34,35 +34,29 @@ int pthread_getschedparam( struct sched_param *param ) { - 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 ( !policy || !param ) + if ( policy == NULL || param == NULL ) { return EINVAL; + } - the_thread = _Thread_Get( thread, &location ); - switch ( location ) { - - case OBJECTS_LOCAL: - api = the_thread->API_Extensions[ THREAD_API_POSIX ]; - if ( policy ) - *policy = api->schedpolicy; - if ( param ) { - *param = api->schedparam; - param->sched_priority = - _POSIX_Priority_From_core( the_thread->current_priority ); - } - _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 ]; + *policy = api->schedpolicy; + *param = api->schedparam; + param->sched_priority = _POSIX_Priority_From_core( + the_thread->current_priority + ); + _Thread_State_release( the_thread, &lock_context ); + return 0; } |