source: rtems/cpukit/score/src/corebarrierwait.c @ 8ae37323

4.115
Last change on this file since 8ae37323 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Wait For The Barrier
5 *  @ingroup ScoreBarrier
6 */
7
8/*
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.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/score/corebarrierimpl.h>
22#include <rtems/score/isrlevel.h>
23#include <rtems/score/threadqimpl.h>
24
25void _CORE_barrier_Wait(
26  CORE_barrier_Control                *the_barrier,
27  Thread_Control                      *executing,
28  Objects_Id                           id,
29  bool                                 wait,
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++;
39  if ( _CORE_barrier_Is_automatic( &the_barrier->Attributes ) ) {
40    if ( the_barrier->number_of_waiting_threads ==
41         the_barrier->Attributes.maximum_count) {
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    }
47  }
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
54  _Thread_queue_Enqueue( &the_barrier->Wait_queue, executing, timeout );
55}
Note: See TracBrowser for help on using the repository browser.