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/pbarrierwait.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 'cpukit/posix/src/pbarrierwait.c')
-rw-r--r-- | cpukit/posix/src/pbarrierwait.c | 50 |
1 files changed, 21 insertions, 29 deletions
diff --git a/cpukit/posix/src/pbarrierwait.c b/cpukit/posix/src/pbarrierwait.c index 86bfba7b09..9200dc0eee 100644 --- a/cpukit/posix/src/pbarrierwait.c +++ b/cpukit/posix/src/pbarrierwait.c @@ -18,9 +18,6 @@ #include "config.h" #endif -#include <pthread.h> -#include <errno.h> - #include <rtems/posix/barrierimpl.h> #include <rtems/score/threadimpl.h> @@ -40,36 +37,31 @@ int pthread_barrier_wait( pthread_barrier_t *barrier ) { - POSIX_Barrier_Control *the_barrier = NULL; - Objects_Locations location; - Thread_Control *executing; + POSIX_Barrier_Control *the_barrier; + ISR_lock_Context lock_context; + Thread_Control *executing; - if ( !barrier ) + if ( barrier == NULL ) { return EINVAL; + } - the_barrier = _POSIX_Barrier_Get( barrier, &location ); - switch ( location ) { - - case OBJECTS_LOCAL: - executing = _Thread_Executing; - _CORE_barrier_Seize( - &the_barrier->Barrier, - executing, - true, - 0, - NULL, - 0 - ); - _Objects_Put( &the_barrier->Object ); - return _POSIX_Barrier_Translate_core_barrier_return_code( - executing->Wait.return_code ); + the_barrier = _POSIX_Barrier_Get( barrier, &lock_context ); -#if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: -#endif - case OBJECTS_ERROR: - break; + if ( the_barrier == NULL ) { + return EINVAL; } - return EINVAL; + executing = _Thread_Executing; + _CORE_barrier_Seize( + &the_barrier->Barrier, + executing, + true, + 0, + NULL, + 0, + &lock_context + ); + return _POSIX_Barrier_Translate_core_barrier_return_code( + executing->Wait.return_code + ); } |