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/rtems/src/barrierrelease.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/rtems/src/barrierrelease.c')
-rw-r--r-- | cpukit/rtems/src/barrierrelease.c | 50 |
1 files changed, 15 insertions, 35 deletions
diff --git a/cpukit/rtems/src/barrierrelease.c b/cpukit/rtems/src/barrierrelease.c index 77937b3c40..a60ea89ba5 100644 --- a/cpukit/rtems/src/barrierrelease.c +++ b/cpukit/rtems/src/barrierrelease.c @@ -18,52 +18,32 @@ #include "config.h" #endif -#include <rtems/system.h> -#include <rtems/rtems/status.h> -#include <rtems/rtems/support.h> #include <rtems/rtems/barrierimpl.h> -#include <rtems/score/thread.h> - -/* - * rtems_barrier_release - * - * This directive releases all threads waiting at a barrier. - * - * Input parameters: - * id - barrier id - * released - pointer to number of threads unblocked - * - * Output parameters: - * RTEMS_SUCCESSFUL - if successful - * error code - if unsuccessful - * *released - number of threads unblocked - */ rtems_status_code rtems_barrier_release( rtems_id id, uint32_t *released ) { - Barrier_Control *the_barrier; - Objects_Locations location; + Barrier_Control *the_barrier; + ISR_lock_Context lock_context; - if ( !released ) + if ( released == NULL ) { return RTEMS_INVALID_ADDRESS; + } - the_barrier = _Barrier_Get( id, &location ); - switch ( location ) { - - case OBJECTS_LOCAL: - *released = _CORE_barrier_Surrender( &the_barrier->Barrier, NULL, 0 ); - _Objects_Put( &the_barrier->Object ); - return RTEMS_SUCCESSFUL; + the_barrier = _Barrier_Get( id, &lock_context ); -#if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: -#endif - case OBJECTS_ERROR: - break; + if ( the_barrier == NULL ) { + return RTEMS_INVALID_ID; } - return RTEMS_INVALID_ID; + _CORE_barrier_Acquire_critical( &the_barrier->Barrier, &lock_context ); + *released = _CORE_barrier_Surrender( + &the_barrier->Barrier, + NULL, + 0, + &lock_context + ); + return RTEMS_SUCCESSFUL; } |