source: rtems/cpukit/score/src/smpbarrierwait.c @ 25f5730f

4.11
Last change on this file since 25f5730f was c499856, checked in by Chris Johns <chrisj@…>, on Mar 20, 2014 at 9:10:47 PM

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

  • Property mode set to 100644
File size: 1.0 KB
Line 
1/*
2 * Copyright (c) 2013-2014 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#if HAVE_CONFIG_H
16  #include "config.h"
17#endif
18
19#include <rtems/score/smpbarrier.h>
20
21void _SMP_barrier_Wait(
22  SMP_barrier_Control *control,
23  SMP_barrier_State *state,
24  unsigned int count
25)
26{
27  unsigned int sense = ~state->sense;
28  unsigned int previous_value;
29
30  state->sense = sense;
31
32  previous_value = _Atomic_Fetch_add_uint(
33    &control->value,
34    1U,
35    ATOMIC_ORDER_RELAXED
36  );
37
38  if ( previous_value + 1U == count ) {
39    _Atomic_Store_uint( &control->value, 0U, ATOMIC_ORDER_RELAXED );
40    _Atomic_Store_uint( &control->sense, sense, ATOMIC_ORDER_RELEASE );
41  } else {
42    while (
43      _Atomic_Load_uint( &control->sense, ATOMIC_ORDER_ACQUIRE ) != sense
44    ) {
45      /* Wait */
46    }
47  }
48}
Note: See TracBrowser for help on using the repository browser.