source: rtems/cpukit/score/include/rtems/score/corebarrierimpl.h @ 3d0c4005

5
Last change on this file since 3d0c4005 was 3d0c4005, checked in by Sebastian Huber <sebastian.huber@…>, on 04/19/16 at 13:07:39

score: Rename _CORE_barrier_Wait()

Rename _CORE_barrier_Wait() into _CORE_barrier_Seize(). Rename
_CORE_barrier_Release() into _CORE_barrier_Surrender(). This avoids
confusion with the ISR lock acquire and release.

  • Property mode set to 100644
File size: 6.5 KB
Line 
1/**
2 * @file
3 *
4 * @brief Inlined Routines Associated with the SuperCore Barrier
5 *
6 * This include file contains all of the inlined routines associated
7 * with the SuperCore barrier.
8 */
9
10/*
11 *  COPYRIGHT (c) 1989-2006.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#ifndef _RTEMS_SCORE_COREBARRIERIMPL_H
20#define _RTEMS_SCORE_COREBARRIERIMPL_H
21
22#include <rtems/score/corebarrier.h>
23#include <rtems/score/thread.h>
24#include <rtems/score/threadqimpl.h>
25#include <rtems/score/watchdog.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31/**
32 * @addtogroup ScoreBarrier
33 */
34/**@{**/
35
36/**
37 *  Core Barrier handler return statuses.
38 */
39typedef enum {
40  /** This status indicates that the operation completed successfully. */
41  CORE_BARRIER_STATUS_SUCCESSFUL,
42  /** This status indicates that the barrier is configured for automatic
43   *  release and the caller tripped the automatic release.  The caller
44   *  thus did not block.
45   */
46  CORE_BARRIER_STATUS_AUTOMATICALLY_RELEASED,
47  /** This status indicates that the thread was blocked waiting for an
48   *  operation to complete and the barrier was deleted.
49   */
50  CORE_BARRIER_WAS_DELETED,
51  /** This status indicates that the calling task was willing to block
52   *  but the operation was unable to complete within the time allotted
53   *  because the resource never became available.
54   */
55  CORE_BARRIER_TIMEOUT
56}   CORE_barrier_Status;
57
58/**
59 *  @brief Core barrier last status value.
60 *
61 *  This is the last status value.
62 */
63#define CORE_BARRIER_STATUS_LAST CORE_BARRIER_TIMEOUT
64
65#define CORE_BARRIER_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
66
67/**
68 *  @brief Initialize core barrier.
69 *
70 *  This routine initializes the barrier based on the parameters passed.
71 *
72 *  @param[in] the_barrier is the barrier to initialize
73 *  @param[in] the_barrier_attributes define the behavior of this instance
74 */
75void _CORE_barrier_Initialize(
76  CORE_barrier_Control       *the_barrier,
77  CORE_barrier_Attributes    *the_barrier_attributes
78);
79
80RTEMS_INLINE_ROUTINE void _CORE_barrier_Destroy(
81  CORE_barrier_Control *the_barrier
82)
83{
84  _Thread_queue_Destroy( &the_barrier->Wait_queue );
85}
86
87void _CORE_barrier_Do_seize(
88  CORE_barrier_Control    *the_barrier,
89  Thread_Control          *executing,
90  bool                     wait,
91  Watchdog_Interval        timeout
92#if defined(RTEMS_MULTIPROCESSING)
93  ,
94  Thread_queue_MP_callout  mp_callout,
95  Objects_Id               mp_id
96#endif
97);
98
99/**
100 *  @brief Wait for the barrier.
101 *
102 *  This routine wait for the barrier to be released.  If the barrier
103 *  is set to automatic and this is the appropriate thread, then it returns
104 *  immediately.  Otherwise, the calling thread is blocked until the barrier
105 *  is released.
106 *
107 *  @param[in] the_barrier is the barrier to wait for
108 *  @param[in,out] executing The currently executing thread.
109 *  @param[in] wait is true if the calling thread is willing to wait
110 *  @param[in] timeout is the number of ticks the calling thread is willing
111 *         to wait if @a wait is true.
112 *  @param[in] mp_callout is the routine to invoke if the
113 *         thread unblocked is remote
114 *  @param[in] mp_id is the id of the object being waited upon
115 *
116 * @note Status is returned via the thread control block.
117 */
118#if defined(RTEMS_MULTIPROCESSING)
119  #define _CORE_barrier_Seize( \
120    the_barrier, \
121    executing, \
122    wait, \
123    timeout, \
124    mp_callout, \
125    mp_id \
126  ) \
127    _CORE_barrier_Do_seize( \
128      the_barrier, \
129      executing, \
130      wait, \
131      timeout, \
132      mp_callout, \
133      mp_id \
134    )
135#else
136  #define _CORE_barrier_Seize( \
137    the_barrier, \
138    executing, \
139    wait, \
140    timeout, \
141    mp_callout, \
142    mp_id \
143  ) \
144    _CORE_barrier_Do_seize( \
145      the_barrier, \
146      executing, \
147      wait, \
148      timeout \
149    )
150#endif
151
152uint32_t _CORE_barrier_Do_surrender(
153  CORE_barrier_Control    *the_barrier
154#if defined(RTEMS_MULTIPROCESSING)
155  ,
156  Thread_queue_MP_callout  mp_callout,
157  Objects_Id               mp_id
158#endif
159);
160
161/**
162 *  @brief Manually release the barrier.
163 *
164 *  This routine manually releases the barrier.  All of the threads waiting
165 *  for the barrier will be readied.
166 *
167 *  @param[in] the_barrier is the barrier to surrender
168 *  @param[in] mp_callout is the routine to invoke if the
169 *         thread unblocked is remote
170 *  @param[in] mp_id is the id of the object for a remote unblock
171 *
172 *  @retval the number of unblocked threads
173 */
174#if defined(RTEMS_MULTIPROCESSING)
175  #define _CORE_barrier_Surrender( \
176    the_barrier, \
177    mp_callout, \
178    mp_id \
179  ) \
180    _CORE_barrier_Do_surrender( \
181      the_barrier, \
182      mp_callout, \
183      mp_id \
184    )
185#else
186  #define _CORE_barrier_Surrender( \
187    the_barrier, \
188    mp_callout, \
189    mp_id \
190  ) \
191    _CORE_barrier_Do_surrender( \
192      the_barrier \
193    )
194#endif
195
196Thread_Control *_CORE_barrier_Was_deleted(
197  Thread_Control     *the_thread,
198  Thread_queue_Queue *queue,
199  ISR_lock_Context   *lock_context
200);
201
202/* Must be a macro due to the multiprocessing dependent parameters */
203#define _CORE_barrier_Flush( \
204  the_barrier, \
205  mp_callout, \
206  mp_id \
207) \
208  do { \
209    ISR_lock_Context _core_barrier_flush_lock_context; \
210    _Thread_queue_Acquire( \
211      &( the_barrier )->Wait_queue, \
212      &_core_barrier_flush_lock_context \
213    ); \
214    _Thread_queue_Flush_critical( \
215      &( the_barrier )->Wait_queue.Queue, \
216      CORE_BARRIER_TQ_OPERATIONS, \
217      _CORE_barrier_Was_deleted, \
218      mp_callout, \
219      mp_id, \
220      &_core_barrier_flush_lock_context \
221    ); \
222  } while ( 0 )
223
224/**
225 * This function returns true if the automatic release attribute is
226 * enabled in the @a attribute_set and false otherwise.
227 *
228 * @param[in] the_attribute is the attribute set to test
229 *
230 * @return true if the priority attribute is enabled
231 */
232RTEMS_INLINE_ROUTINE bool _CORE_barrier_Is_automatic(
233  CORE_barrier_Attributes *the_attribute
234)
235{
236   return
237     (the_attribute->discipline == CORE_BARRIER_AUTOMATIC_RELEASE);
238}
239
240/**
241 * This routine returns the number of threads currently waiting at the barrier.
242 *
243 * @param[in] the_barrier is the barrier to obtain the number of blocked
244 *            threads for
245 * @return the current count of this barrier
246 */
247RTEMS_INLINE_ROUTINE uint32_t  _CORE_barrier_Get_number_of_waiting_threads(
248  CORE_barrier_Control  *the_barrier
249)
250{
251  return the_barrier->number_of_waiting_threads;
252}
253
254/** @} */
255
256#ifdef __cplusplus
257}
258#endif
259
260#endif
261/* end of include file */
Note: See TracBrowser for help on using the repository browser.