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

4.11
Last change on this file since bb2d9f9 was bb2d9f9, checked in by Sebastian Huber <sebastian.huber@…>, on Jul 19, 2013 at 9:00:19 AM

score: Create barrier implementation header

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

  • Property mode set to 100644
File size: 1.7 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/states.h>
25#include <rtems/score/thread.h>
26#include <rtems/score/threadq.h>
27
28void _CORE_barrier_Wait(
29  CORE_barrier_Control                *the_barrier,
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  Thread_Control *executing;
37  ISR_Level       level;
38
39  executing = _Thread_Executing;
40  executing->Wait.return_code = CORE_BARRIER_STATUS_SUCCESSFUL;
41  _ISR_Disable( level );
42  the_barrier->number_of_waiting_threads++;
43  if ( _CORE_barrier_Is_automatic( &the_barrier->Attributes ) ) {
44    if ( the_barrier->number_of_waiting_threads ==
45         the_barrier->Attributes.maximum_count) {
46      executing->Wait.return_code = CORE_BARRIER_STATUS_AUTOMATICALLY_RELEASED;
47      _ISR_Enable( level );
48      _CORE_barrier_Release( the_barrier, id, api_barrier_mp_support );
49      return;
50    }
51  }
52
53  _Thread_queue_Enter_critical_section( &the_barrier->Wait_queue );
54  executing->Wait.queue          = &the_barrier->Wait_queue;
55  executing->Wait.id             = id;
56  _ISR_Enable( level );
57
58  _Thread_queue_Enqueue( &the_barrier->Wait_queue, timeout );
59}
Note: See TracBrowser for help on using the repository browser.