[9c191ee] | 1 | /* |
---|
| 2 | * SuperCore Barrier Handler |
---|
| 3 | * |
---|
| 4 | * DESCRIPTION: |
---|
| 5 | * |
---|
| 6 | * This package is part of the implementation of the SuperCore Barrier Handler. |
---|
| 7 | * |
---|
| 8 | * COPYRIGHT (c) 1989-2006. |
---|
| 9 | * On-Line Applications Research Corporation (OAR). |
---|
| 10 | * |
---|
| 11 | * The license and distribution terms for this file may be |
---|
| 12 | * found in the file LICENSE in this distribution or at |
---|
| 13 | * http://www.rtems.com/license/LICENSE. |
---|
| 14 | * |
---|
| 15 | * $Id$ |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | #if HAVE_CONFIG_H |
---|
| 19 | #include "config.h" |
---|
| 20 | #endif |
---|
| 21 | |
---|
| 22 | #include <rtems/system.h> |
---|
| 23 | #include <rtems/score/isr.h> |
---|
| 24 | #include <rtems/score/corebarrier.h> |
---|
| 25 | #include <rtems/score/states.h> |
---|
| 26 | #include <rtems/score/thread.h> |
---|
| 27 | #include <rtems/score/threadq.h> |
---|
| 28 | |
---|
| 29 | /*PAGE |
---|
| 30 | * |
---|
| 31 | * _CORE_barrier_Wait |
---|
| 32 | * |
---|
| 33 | * Input parameters: |
---|
| 34 | * the_barrier - pointer to barrier control block |
---|
| 35 | * id - id of object to wait on |
---|
[aae7f1a1] | 36 | * wait - true if wait is allowed, false otherwise |
---|
[9c191ee] | 37 | * timeout - number of ticks to wait (0 means forever) |
---|
| 38 | * api_barrier_mp_support - api dependent MP support actions |
---|
| 39 | * |
---|
| 40 | * Output parameters: NONE |
---|
| 41 | * |
---|
| 42 | * INTERRUPT LATENCY: |
---|
| 43 | * available |
---|
| 44 | * wait |
---|
| 45 | */ |
---|
| 46 | |
---|
| 47 | void _CORE_barrier_Wait( |
---|
| 48 | CORE_barrier_Control *the_barrier, |
---|
| 49 | Objects_Id id, |
---|
[484a769] | 50 | bool wait, |
---|
[9c191ee] | 51 | Watchdog_Interval timeout, |
---|
| 52 | CORE_barrier_API_mp_support_callout api_barrier_mp_support |
---|
| 53 | ) |
---|
| 54 | { |
---|
| 55 | Thread_Control *executing; |
---|
| 56 | ISR_Level level; |
---|
| 57 | |
---|
| 58 | executing = _Thread_Executing; |
---|
| 59 | executing->Wait.return_code = CORE_BARRIER_STATUS_SUCCESSFUL; |
---|
| 60 | _ISR_Disable( level ); |
---|
| 61 | the_barrier->number_of_waiting_threads++; |
---|
[b2b77956] | 62 | if ( _CORE_barrier_Is_automatic( &the_barrier->Attributes ) ) { |
---|
[28352fae] | 63 | if ( the_barrier->number_of_waiting_threads == |
---|
[b2b77956] | 64 | the_barrier->Attributes.maximum_count) { |
---|
[9c191ee] | 65 | executing->Wait.return_code = CORE_BARRIER_STATUS_AUTOMATICALLY_RELEASED; |
---|
| 66 | _ISR_Enable( level ); |
---|
| 67 | _CORE_barrier_Release( the_barrier, id, api_barrier_mp_support ); |
---|
| 68 | return; |
---|
| 69 | } |
---|
[28352fae] | 70 | } |
---|
[9c191ee] | 71 | |
---|
| 72 | _Thread_queue_Enter_critical_section( &the_barrier->Wait_queue ); |
---|
| 73 | executing->Wait.queue = &the_barrier->Wait_queue; |
---|
| 74 | executing->Wait.id = id; |
---|
| 75 | _ISR_Enable( level ); |
---|
| 76 | |
---|
| 77 | _Thread_queue_Enqueue( &the_barrier->Wait_queue, timeout ); |
---|
| 78 | } |
---|