source: rtems/cpukit/score/include/rtems/score/corebarrierimpl.h @ 114e408

5
Last change on this file since 114e408 was 114e408, checked in by Sebastian Huber <sebastian.huber@…>, on 08/22/16 at 11:17:05

score: Simplify thread queue acquire/release

  • Property mode set to 100644
File size: 4.2 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/status.h>
24#include <rtems/score/threadqimpl.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/**
31 * @addtogroup ScoreBarrier
32 */
33/**@{**/
34
35#define CORE_BARRIER_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
36
37/**
38 *  @brief Initialize core barrier.
39 *
40 *  This routine initializes the barrier based on the parameters passed.
41 *
42 *  @param[in] the_barrier is the barrier to initialize
43 *  @param[in] the_barrier_attributes define the behavior of this instance
44 */
45void _CORE_barrier_Initialize(
46  CORE_barrier_Control       *the_barrier,
47  CORE_barrier_Attributes    *the_barrier_attributes
48);
49
50RTEMS_INLINE_ROUTINE void _CORE_barrier_Destroy(
51  CORE_barrier_Control *the_barrier
52)
53{
54  _Thread_queue_Destroy( &the_barrier->Wait_queue );
55}
56
57RTEMS_INLINE_ROUTINE void _CORE_barrier_Acquire_critical(
58  CORE_barrier_Control *the_barrier,
59  Thread_queue_Context *queue_context
60)
61{
62  _Thread_queue_Acquire_critical( &the_barrier->Wait_queue, queue_context );
63}
64
65RTEMS_INLINE_ROUTINE void _CORE_barrier_Release(
66  CORE_barrier_Control *the_barrier,
67  Thread_queue_Context *queue_context
68)
69{
70  _Thread_queue_Release( &the_barrier->Wait_queue, queue_context );
71}
72
73/**
74 *  @brief Wait for the barrier.
75 *
76 *  This routine wait for the barrier to be released.  If the barrier
77 *  is set to automatic and this is the appropriate thread, then it returns
78 *  immediately.  Otherwise, the calling thread is blocked until the barrier
79 *  is released.
80 *
81 *  @param[in] the_barrier is the barrier to wait for
82 *  @param[in,out] executing The currently executing thread.
83 *  @param[in] wait is true if the calling thread is willing to wait
84 *
85 * @return The method status.
86 */
87Status_Control _CORE_barrier_Seize(
88  CORE_barrier_Control *the_barrier,
89  Thread_Control       *executing,
90  bool                  wait,
91  Thread_queue_Context *queue_context
92);
93
94uint32_t _CORE_barrier_Do_flush(
95  CORE_barrier_Control      *the_barrier,
96  Thread_queue_Flush_filter  filter,
97  Thread_queue_Context      *queue_context
98);
99
100/**
101 *  @brief Manually release the barrier.
102 *
103 *  This routine manually releases the barrier.  All of the threads waiting
104 *  for the barrier will be readied.
105 *
106 *  @param[in] the_barrier is the barrier to surrender
107 *  @param[in] mp_callout is the routine to invoke if the
108 *         thread unblocked is remote
109 *
110 *  @retval the number of unblocked threads
111 */
112RTEMS_INLINE_ROUTINE uint32_t _CORE_barrier_Surrender(
113  CORE_barrier_Control *the_barrier,
114  Thread_queue_Context *queue_context
115)
116{
117  return _CORE_barrier_Do_flush(
118    the_barrier,
119    _Thread_queue_Flush_default_filter,
120    queue_context
121  );
122}
123
124RTEMS_INLINE_ROUTINE void _CORE_barrier_Flush(
125  CORE_barrier_Control *the_barrier,
126  Thread_queue_Context *queue_context
127)
128{
129  _CORE_barrier_Do_flush(
130    the_barrier,
131    _Thread_queue_Flush_status_object_was_deleted,
132    queue_context
133  );
134}
135
136/**
137 * This function returns true if the automatic release attribute is
138 * enabled in the @a attribute_set and false otherwise.
139 *
140 * @param[in] the_attribute is the attribute set to test
141 *
142 * @return true if the priority attribute is enabled
143 */
144RTEMS_INLINE_ROUTINE bool _CORE_barrier_Is_automatic(
145  CORE_barrier_Attributes *the_attribute
146)
147{
148   return
149     (the_attribute->discipline == CORE_BARRIER_AUTOMATIC_RELEASE);
150}
151
152/**
153 * This routine returns the number of threads currently waiting at the barrier.
154 *
155 * @param[in] the_barrier is the barrier to obtain the number of blocked
156 *            threads for
157 * @return the current count of this barrier
158 */
159RTEMS_INLINE_ROUTINE uint32_t  _CORE_barrier_Get_number_of_waiting_threads(
160  CORE_barrier_Control  *the_barrier
161)
162{
163  return the_barrier->number_of_waiting_threads;
164}
165
166/** @} */
167
168#ifdef __cplusplus
169}
170#endif
171
172#endif
173/* end of include file */
Note: See TracBrowser for help on using the repository browser.