diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-17 13:56:02 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-20 07:49:40 +0200 |
commit | 64fe16636b45d7a3d64654707234b885f7ccbaf6 (patch) | |
tree | 525fd986ba08debe71c11878f64023ecc196a57b /cpukit/posix/src | |
parent | posix: Rework thread cancellation (diff) | |
download | rtems-64fe16636b45d7a3d64654707234b885f7ccbaf6.tar.bz2 |
posix: Avoid Giant lock for pthread_kill()
Update #2555.
Diffstat (limited to 'cpukit/posix/src')
-rw-r--r-- | cpukit/posix/src/pthreadkill.c | 55 |
1 files changed, 22 insertions, 33 deletions
diff --git a/cpukit/posix/src/pthreadkill.c b/cpukit/posix/src/pthreadkill.c index 897f4c502a..eb027461cb 100644 --- a/cpukit/posix/src/pthreadkill.c +++ b/cpukit/posix/src/pthreadkill.c @@ -24,53 +24,42 @@ #include <signal.h> #include <errno.h> -#include <rtems/posix/pthreadimpl.h> +#include <rtems/posix/threadsup.h> #include <rtems/posix/psignalimpl.h> -#include <rtems/score/isr.h> #include <rtems/score/threadimpl.h> -int pthread_kill( - pthread_t thread, - int sig -) +int pthread_kill( pthread_t thread, int sig ) { - POSIX_API_Control *api; - Thread_Control *the_thread; - Objects_Locations location; + Thread_Control *the_thread; + ISR_lock_Context lock_context; + POSIX_API_Control *api; + Per_CPU_Control *cpu_self; if ( !is_valid_signo( sig ) ) { return EINVAL; } - the_thread = _Thread_Get( thread, &location ); - switch ( location ) { + the_thread = _Thread_Get_interrupt_disable( thread, &lock_context ); - case OBJECTS_LOCAL: - /* - * If sig == 0 then just validate arguments - */ - - api = the_thread->API_Extensions[ THREAD_API_POSIX ]; + if ( the_thread == NULL ) { + return ESRCH; + } - if ( _POSIX_signals_Vectors[ sig ].sa_handler == SIG_IGN ) { - _Objects_Put( &the_thread->Object ); - return 0; - } + api = the_thread->API_Extensions[ THREAD_API_POSIX ]; - /* XXX critical section */ + if ( _POSIX_signals_Vectors[ sig ].sa_handler == SIG_IGN ) { + _ISR_lock_ISR_enable( &lock_context ); + return 0; + } - api->signals_pending |= signo_to_mask( sig ); + /* XXX critical section */ - (void) _POSIX_signals_Unblock_thread( the_thread, sig, NULL ); - _Objects_Put( &the_thread->Object ); - return 0; + api->signals_pending |= signo_to_mask( sig ); -#if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: -#endif - case OBJECTS_ERROR: - break; - } + cpu_self = _Thread_Dispatch_disable_critical( &lock_context ); + _ISR_lock_ISR_enable( &lock_context ); - return ESRCH; + (void) _POSIX_signals_Unblock_thread( the_thread, sig, NULL ); + _Thread_Dispatch_enable( cpu_self ); + return 0; } |