[5a58b1e] | 1 | /** |
---|
| 2 | * @file |
---|
[9c191ee] | 3 | * |
---|
[5a58b1e] | 4 | * @brief Wait For The Barrier |
---|
| 5 | * @ingroup ScoreBarrier |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | /* |
---|
[9c191ee] | 9 | * COPYRIGHT (c) 1989-2006. |
---|
| 10 | * On-Line Applications Research Corporation (OAR). |
---|
| 11 | * |
---|
| 12 | * The license and distribution terms for this file may be |
---|
| 13 | * found in the file LICENSE in this distribution or at |
---|
| 14 | * http://www.rtems.com/license/LICENSE. |
---|
| 15 | */ |
---|
| 16 | |
---|
| 17 | #if HAVE_CONFIG_H |
---|
| 18 | #include "config.h" |
---|
| 19 | #endif |
---|
| 20 | |
---|
[bb2d9f9] | 21 | #include <rtems/score/corebarrierimpl.h> |
---|
[a112364] | 22 | #include <rtems/score/isrlevel.h> |
---|
| 23 | #include <rtems/score/threadqimpl.h> |
---|
[9c191ee] | 24 | |
---|
| 25 | void _CORE_barrier_Wait( |
---|
| 26 | CORE_barrier_Control *the_barrier, |
---|
[0444947e] | 27 | Thread_Control *executing, |
---|
[9c191ee] | 28 | Objects_Id id, |
---|
[484a769] | 29 | bool wait, |
---|
[9c191ee] | 30 | Watchdog_Interval timeout, |
---|
| 31 | CORE_barrier_API_mp_support_callout api_barrier_mp_support |
---|
| 32 | ) |
---|
| 33 | { |
---|
| 34 | ISR_Level level; |
---|
| 35 | |
---|
| 36 | executing->Wait.return_code = CORE_BARRIER_STATUS_SUCCESSFUL; |
---|
| 37 | _ISR_Disable( level ); |
---|
| 38 | the_barrier->number_of_waiting_threads++; |
---|
[b2b77956] | 39 | if ( _CORE_barrier_Is_automatic( &the_barrier->Attributes ) ) { |
---|
[28352fae] | 40 | if ( the_barrier->number_of_waiting_threads == |
---|
[b2b77956] | 41 | the_barrier->Attributes.maximum_count) { |
---|
[9c191ee] | 42 | executing->Wait.return_code = CORE_BARRIER_STATUS_AUTOMATICALLY_RELEASED; |
---|
| 43 | _ISR_Enable( level ); |
---|
| 44 | _CORE_barrier_Release( the_barrier, id, api_barrier_mp_support ); |
---|
| 45 | return; |
---|
| 46 | } |
---|
[28352fae] | 47 | } |
---|
[9c191ee] | 48 | |
---|
| 49 | _Thread_queue_Enter_critical_section( &the_barrier->Wait_queue ); |
---|
| 50 | executing->Wait.queue = &the_barrier->Wait_queue; |
---|
| 51 | executing->Wait.id = id; |
---|
| 52 | _ISR_Enable( level ); |
---|
| 53 | |
---|
[07332ae] | 54 | _Thread_queue_Enqueue( &the_barrier->Wait_queue, executing, timeout ); |
---|
[9c191ee] | 55 | } |
---|