summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/barrierwait.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-20 14:01:02 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-22 09:25:09 +0200
commitf27383a518836881b7b9b88e88d2e31d5b23d048 (patch)
treeecdccfa9c902a5a8db0918026e8074af0b581a6a /cpukit/rtems/src/barrierwait.c
parentscore: Add _Thread_queue_Flush_default_filter() (diff)
downloadrtems-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/barrierwait.c')
-rw-r--r--cpukit/rtems/src/barrierwait.c51
1 files changed, 21 insertions, 30 deletions
diff --git a/cpukit/rtems/src/barrierwait.c b/cpukit/rtems/src/barrierwait.c
index f8f9ac3809..b5f23d7bb5 100644
--- a/cpukit/rtems/src/barrierwait.c
+++ b/cpukit/rtems/src/barrierwait.c
@@ -18,9 +18,6 @@
#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/threadimpl.h>
@@ -31,33 +28,27 @@ rtems_status_code rtems_barrier_wait(
rtems_interval timeout
)
{
- Barrier_Control *the_barrier;
- Objects_Locations location;
- Thread_Control *executing;
-
- the_barrier = _Barrier_Get( id, &location );
- switch ( location ) {
-
- case OBJECTS_LOCAL:
- executing = _Thread_Executing;
- _CORE_barrier_Seize(
- &the_barrier->Barrier,
- executing,
- true,
- timeout,
- NULL,
- 0
- );
- _Objects_Put( &the_barrier->Object );
- return _Barrier_Translate_core_barrier_return_code(
- executing->Wait.return_code );
-
-#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE:
-#endif
- case OBJECTS_ERROR:
- break;
+ Barrier_Control *the_barrier;
+ ISR_lock_Context lock_context;
+ Thread_Control *executing;
+
+ the_barrier = _Barrier_Get( id, &lock_context );
+
+ if ( the_barrier == NULL ) {
+ return RTEMS_INVALID_ID;
}
- return RTEMS_INVALID_ID;
+ executing = _Thread_Executing;
+ _CORE_barrier_Seize(
+ &the_barrier->Barrier,
+ executing,
+ true,
+ timeout,
+ NULL,
+ 0,
+ &lock_context
+ );
+ return _Barrier_Translate_core_barrier_return_code(
+ executing->Wait.return_code
+ );
}