source: rtems/cpukit/score/src/corebarrierwait.c @ fe6c170c

4.11
Last change on this file since fe6c170c was fe6c170c, checked in by Sebastian Huber <sebastian.huber@…>, on Jul 24, 2013 at 2:19:52 PM

score: Create states implementation header

Move implementation specific parts of states.h and states.inl into new
header file statesimpl.h. The states.h contains now only the
application visible API.

  • 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.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/score/isr.h>
23#include <rtems/score/corebarrierimpl.h>
24#include <rtems/score/thread.h>
25#include <rtems/score/threadq.h>
26
27void _CORE_barrier_Wait(
28  CORE_barrier_Control                *the_barrier,
29  Thread_Control                      *executing,
30  Objects_Id                           id,
31  bool                                 wait,
32  Watchdog_Interval                    timeout,
33  CORE_barrier_API_mp_support_callout  api_barrier_mp_support
34)
35{
36  ISR_Level       level;
37
38  executing->Wait.return_code = CORE_BARRIER_STATUS_SUCCESSFUL;
39  _ISR_Disable( level );
40  the_barrier->number_of_waiting_threads++;
41  if ( _CORE_barrier_Is_automatic( &the_barrier->Attributes ) ) {
42    if ( the_barrier->number_of_waiting_threads ==
43         the_barrier->Attributes.maximum_count) {
44      executing->Wait.return_code = CORE_BARRIER_STATUS_AUTOMATICALLY_RELEASED;
45      _ISR_Enable( level );
46      _CORE_barrier_Release( the_barrier, id, api_barrier_mp_support );
47      return;
48    }
49  }
50
51  _Thread_queue_Enter_critical_section( &the_barrier->Wait_queue );
52  executing->Wait.queue          = &the_barrier->Wait_queue;
53  executing->Wait.id             = id;
54  _ISR_Enable( level );
55
56  _Thread_queue_Enqueue( &the_barrier->Wait_queue, timeout );
57}
Note: See TracBrowser for help on using the repository browser.