source: rtems/cpukit/score/src/corebarrierwait.c @ 7d9a426

4.115
Last change on this file since 7d9a426 was 0444947e, checked in by Sebastian Huber <sebastian.huber@…>, on 07/19/13 at 09:07:37

score: Avoid direct usage of _Thread_Executing

Pass the executing thread as a function parameter. Obtain the executing
thread inside a thread dispatch critical section to avoid problems on
SMP.

  • 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/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  Thread_Control                      *executing,
31  Objects_Id                           id,
32  bool                                 wait,
33  Watchdog_Interval                    timeout,
34  CORE_barrier_API_mp_support_callout  api_barrier_mp_support
35)
36{
37  ISR_Level       level;
38
39  executing->Wait.return_code = CORE_BARRIER_STATUS_SUCCESSFUL;
40  _ISR_Disable( level );
41  the_barrier->number_of_waiting_threads++;
42  if ( _CORE_barrier_Is_automatic( &the_barrier->Attributes ) ) {
43    if ( the_barrier->number_of_waiting_threads ==
44         the_barrier->Attributes.maximum_count) {
45      executing->Wait.return_code = CORE_BARRIER_STATUS_AUTOMATICALLY_RELEASED;
46      _ISR_Enable( level );
47      _CORE_barrier_Release( the_barrier, id, api_barrier_mp_support );
48      return;
49    }
50  }
51
52  _Thread_queue_Enter_critical_section( &the_barrier->Wait_queue );
53  executing->Wait.queue          = &the_barrier->Wait_queue;
54  executing->Wait.id             = id;
55  _ISR_Enable( level );
56
57  _Thread_queue_Enqueue( &the_barrier->Wait_queue, timeout );
58}
Note: See TracBrowser for help on using the repository browser.