diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-04-20 14:01:02 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-04-22 09:25:09 +0200 |
commit | f27383a518836881b7b9b88e88d2e31d5b23d048 (patch) | |
tree | ecdccfa9c902a5a8db0918026e8074af0b581a6a /cpukit/posix/src/pbarrierdestroy.c | |
parent | score: Add _Thread_queue_Flush_default_filter() (diff) | |
download | rtems-f27383a518836881b7b9b88e88d2e31d5b23d048.tar.bz2 |
score: Avoid Giant lock for barriers
Use _Thread_queue_Flush_critical() to atomically release the barrier.
Update #2555.
Diffstat (limited to '')
-rw-r--r-- | cpukit/posix/src/pbarrierdestroy.c | 45 |
1 files changed, 18 insertions, 27 deletions
diff --git a/cpukit/posix/src/pbarrierdestroy.c b/cpukit/posix/src/pbarrierdestroy.c index 4b9a0fdca9..709644bf4e 100644 --- a/cpukit/posix/src/pbarrierdestroy.c +++ b/cpukit/posix/src/pbarrierdestroy.c @@ -18,10 +18,6 @@ #include "config.h" #endif -#include <pthread.h> -#include <errno.h> - -#include <rtems/system.h> #include <rtems/posix/barrierimpl.h> /** @@ -39,37 +35,32 @@ int pthread_barrier_destroy( pthread_barrier_t *barrier ) { - POSIX_Barrier_Control *the_barrier = NULL; - Objects_Locations location; + POSIX_Barrier_Control *the_barrier; + ISR_lock_Context lock_context; - if ( !barrier ) + if ( barrier == NULL ) { return EINVAL; + } _Objects_Allocator_lock(); - the_barrier = _POSIX_Barrier_Get( barrier, &location ); - switch ( location ) { + the_barrier = _POSIX_Barrier_Get( barrier, &lock_context ); - case OBJECTS_LOCAL: - if ( the_barrier->Barrier.number_of_waiting_threads != 0 ) { - _Objects_Put( &the_barrier->Object ); - return EBUSY; - } - - _Objects_Close( &_POSIX_Barrier_Information, &the_barrier->Object ); - _Objects_Put( &the_barrier->Object ); + if ( the_barrier == NULL ) { + _Objects_Allocator_unlock(); + return EINVAL; + } - _POSIX_Barrier_Free( the_barrier ); - _Objects_Allocator_unlock(); - return 0; + _CORE_barrier_Acquire_critical( &the_barrier->Barrier, &lock_context ); -#if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: -#endif - case OBJECTS_ERROR: - break; + if ( the_barrier->Barrier.number_of_waiting_threads != 0 ) { + _CORE_barrier_Release( &the_barrier->Barrier, &lock_context ); + _Objects_Allocator_unlock(); + return EBUSY; } + _Objects_Close( &_POSIX_Barrier_Information, &the_barrier->Object ); + _CORE_barrier_Release( &the_barrier->Barrier, &lock_context ); + _POSIX_Barrier_Free( the_barrier ); _Objects_Allocator_unlock(); - - return EINVAL; + return 0; } |