source: rtems/cpukit/include/rtems/rtems/barrier.h @ 278c7daa

Last change on this file since 278c7daa was 55c6cb1d, checked in by Sebastian Huber <sebastian.huber@…>, on 04/22/21 at 13:57:19

rtems: Clarify constraints in documentation

  • Property mode set to 100644
File size: 12.5 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @brief This header file defines the Barrier Manager API.
7 */
8
9/*
10 * Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de)
11 * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR)
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 *    notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 *    notice, this list of conditions and the following disclaimer in the
20 *    documentation and/or other materials provided with the distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 */
34
35/*
36 * This file is part of the RTEMS quality process and was automatically
37 * generated.  If you find something that needs to be fixed or
38 * worded better please post a report or patch to an RTEMS mailing list
39 * or raise a bug report:
40 *
41 * https://www.rtems.org/bugs.html
42 *
43 * For information on updating and regenerating please refer to the How-To
44 * section in the Software Requirements Engineering chapter of the
45 * RTEMS Software Engineering manual.  The manual is provided as a part of
46 * a release.  For development sources please refer to the online
47 * documentation at:
48 *
49 * https://docs.rtems.org
50 */
51
52/* Generated from spec:/rtems/barrier/if/header */
53
54#ifndef _RTEMS_RTEMS_BARRIER_H
55#define _RTEMS_RTEMS_BARRIER_H
56
57#include <stdint.h>
58#include <rtems/rtems/attr.h>
59#include <rtems/rtems/status.h>
60#include <rtems/rtems/types.h>
61
62#ifdef __cplusplus
63extern "C" {
64#endif
65
66/* Generated from spec:/rtems/barrier/if/group */
67
68/**
69 * @defgroup RTEMSAPIClassicBarrier Barrier Manager
70 *
71 * @ingroup RTEMSAPIClassic
72 *
73 * @brief The Barrier Manager provides a unique synchronization capability
74 *   which can be used to have a set of tasks block and be unblocked as a set.
75 */
76
77/* Generated from spec:/rtems/barrier/if/create */
78
79/**
80 * @ingroup RTEMSAPIClassicBarrier
81 *
82 * @brief Creates a barrier.
83 *
84 * @param name is the object name of the barrier.
85 *
86 * @param attribute_set is the attribute set of the barrier.
87 *
88 * @param maximum_waiters is the maximum count of waiters on an automatic
89 *   release barrier.
90 *
91 * @param id is the pointer to an object identifier variable.  When the
92 *   directive call is successful, the identifier of the created barrier will
93 *   be stored in this variable.
94 *
95 * This directive creates a barrier which resides on the local node.  The
96 * barrier has the user-defined object name specified in ``name`` and the
97 * initial count specified in ``attribute_set``.  The assigned object
98 * identifier is returned in ``id``.  This identifier is used to access the
99 * barrier with other barrier related directives.
100 *
101 * The **attribute set** specified in ``attribute_set`` is built through a
102 * *bitwise or* of the attribute constants described below.  Not all
103 * combinations of attributes are allowed.  Some attributes are mutually
104 * exclusive.  If mutually exclusive attributes are combined, the behaviour is
105 * undefined.  Attributes not mentioned below are not evaluated by this
106 * directive and have no effect.  Default attributes can be selected by using
107 * the #RTEMS_DEFAULT_ATTRIBUTES constant.
108 *
109 * The **barrier class** is selected by the mutually exclusive
110 * #RTEMS_BARRIER_MANUAL_RELEASE and #RTEMS_BARRIER_AUTOMATIC_RELEASE
111 * attributes.
112 *
113 * * The **manual release class** is the default and can be emphasized through
114 *   use of the #RTEMS_BARRIER_MANUAL_RELEASE attribute.  For this class, there
115 *   is no limit on the number of tasks that will block at the barrier. Only
116 *   when the rtems_barrier_release() directive is invoked, are the tasks
117 *   waiting at the barrier unblocked.
118 *
119 * * The **automatic release class** is selected by the
120 *   #RTEMS_BARRIER_AUTOMATIC_RELEASE attribute.  For this class, tasks calling
121 *   the rtems_barrier_wait() directive will block until there are
122 *   ``maximum_waiters`` minus one tasks waiting at the barrier.  When the
123 *   ``maximum_waiters`` task invokes the rtems_barrier_wait() directive, the
124 *   previous ``maximum_waiters`` - 1 tasks are automatically released and the
125 *   caller returns.
126 *
127 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
128 *
129 * @retval ::RTEMS_INVALID_NAME The ``name`` parameter was invalid.
130 *
131 * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL.
132 *
133 * @retval ::RTEMS_INVALID_NUMBER The ``maximum_waiters`` parameter was 0 for
134 *   an automatic release barrier.
135 *
136 * @retval ::RTEMS_TOO_MANY There was no inactive object available to create a
137 *   barrier.  The number of barriers available to the application is
138 *   configured through the #CONFIGURE_MAXIMUM_BARRIERS application
139 *   configuration option.
140 *
141 * @par Notes
142 * For control and maintenance of the barrier, RTEMS allocates a BCB from the
143 * local BCB free pool and initializes it.
144 *
145 * @par Constraints
146 * @parblock
147 * The following constraints apply to this directive:
148 *
149 * * The directive may be called from within device driver initialization
150 *   context.
151 *
152 * * The directive may be called from within task context.
153 *
154 * * The directive may obtain and release the object allocator mutex.  This may
155 *   cause the calling task to be preempted.
156 *
157 * * The number of barriers available to the application is configured through
158 *   the #CONFIGURE_MAXIMUM_BARRIERS application configuration option.
159 *
160 * * Where the object class corresponding to the directive is configured to use
161 *   unlimited objects, the directive may allocate memory from the RTEMS
162 *   Workspace.
163 * @endparblock
164 */
165rtems_status_code rtems_barrier_create(
166  rtems_name      name,
167  rtems_attribute attribute_set,
168  uint32_t        maximum_waiters,
169  rtems_id       *id
170);
171
172/* Generated from spec:/rtems/barrier/if/ident */
173
174/**
175 * @ingroup RTEMSAPIClassicBarrier
176 *
177 * @brief Identifies a barrier by the object name.
178 *
179 * @param name is the object name to look up.
180 *
181 * @param[out] id is the pointer to an object identifier variable.  When the
182 *   directive call is successful, the object identifier of an object with the
183 *   specified name will be stored in this variable.
184 *
185 * This directive obtains a barrier identifier associated with the barrier name
186 * specified in ``name``.
187 *
188 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
189 *
190 * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL.
191 *
192 * @retval ::RTEMS_INVALID_NAME The ``name`` parameter was 0.
193 *
194 * @retval ::RTEMS_INVALID_NAME There was no object with the specified name on
195 *   the local node.
196 *
197 * @par Notes
198 * @parblock
199 * If the barrier name is not unique, then the barrier identifier will match
200 * the first barrier with that name in the search order.  However, this barrier
201 * identifier is not guaranteed to correspond to the desired barrier.
202 *
203 * The objects are searched from lowest to the highest index.  Only the local
204 * node is searched.
205 *
206 * The barrier identifier is used with other barrier related directives to
207 * access the barrier.
208 * @endparblock
209 *
210 * @par Constraints
211 * @parblock
212 * The following constraints apply to this directive:
213 *
214 * * The directive may be called from within any runtime context.
215 *
216 * * The directive will not cause the calling task to be preempted.
217 * @endparblock
218 */
219rtems_status_code rtems_barrier_ident( rtems_name name, rtems_id *id );
220
221/* Generated from spec:/rtems/barrier/if/delete */
222
223/**
224 * @ingroup RTEMSAPIClassicBarrier
225 *
226 * @brief Deletes the barrier.
227 *
228 * @param id is the barrier identifier.
229 *
230 * This directive deletes the barrier specified by ``id``.  All tasks blocked
231 * waiting for the barrier to be released will be readied and returned a status
232 * code which indicates that the barrier was deleted.
233 *
234 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
235 *
236 * @retval ::RTEMS_INVALID_ID There was no barrier associated with the
237 *   identifier specified by ``id``.
238 *
239 * @par Notes
240 * The BCB for the deleted barrier is reclaimed by RTEMS.
241 *
242 * @par Constraints
243 * @parblock
244 * The following constraints apply to this directive:
245 *
246 * * The directive may be called from within device driver initialization
247 *   context.
248 *
249 * * The directive may be called from within task context.
250 *
251 * * The directive may obtain and release the object allocator mutex.  This may
252 *   cause the calling task to be preempted.
253 *
254 * * The calling task does not have to be the task that created the object.
255 *   Any local task that knows the object identifier can delete the object.
256 *
257 * * Where the object class corresponding to the directive is configured to use
258 *   unlimited objects, the directive may free memory to the RTEMS Workspace.
259 * @endparblock
260 */
261rtems_status_code rtems_barrier_delete( rtems_id id );
262
263/* Generated from spec:/rtems/barrier/if/wait */
264
265/**
266 * @ingroup RTEMSAPIClassicBarrier
267 *
268 * @brief Waits at the barrier.
269 *
270 * @param id is the barrier identifier.
271 *
272 * @param timeout is the timeout in clock ticks.  Use #RTEMS_NO_TIMEOUT to wait
273 *   potentially forever.
274 *
275 * This directive waits at the barrier specified by ``id``.  The ``timeout``
276 * parameter defines how long the calling task is willing to wait.  Use
277 * #RTEMS_NO_TIMEOUT to wait potentially forever, otherwise set a timeout
278 * interval in clock ticks.
279 *
280 * Conceptually, the calling task should always be thought of as blocking when
281 * it makes this call and being unblocked when the barrier is released.  If the
282 * barrier is configured for manual release, this rule of thumb will always be
283 * valid.  If the barrier is configured for automatic release, all callers will
284 * block except for the one which trips the automatic release condition.
285 *
286 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
287 *
288 * @retval ::RTEMS_INVALID_ID There was no barrier associated with the
289 *   identifier specified by ``id``.
290 *
291 * @retval ::RTEMS_TIMEOUT The timeout happened while the calling task was
292 *   waiting at the barrier.
293 *
294 * @retval ::RTEMS_OBJECT_WAS_DELETED The barrier was deleted while the calling
295 *   task was waiting at the barrier.
296 *
297 * @par Notes
298 * For automatic release barriers, the maximum count of waiting tasks is
299 * defined during barrier creation, see rtems_barrier_create().
300 *
301 * @par Constraints
302 * @parblock
303 * The following constraints apply to this directive:
304 *
305 * * The directive may be called from within task context.
306 *
307 * * The timeout functionality of the directive requires a clock tick.
308 * @endparblock
309 */
310rtems_status_code rtems_barrier_wait( rtems_id id, rtems_interval timeout );
311
312/* Generated from spec:/rtems/barrier/if/release */
313
314/**
315 * @ingroup RTEMSAPIClassicBarrier
316 *
317 * @brief Releases the barrier.
318 *
319 * @param id is the barrier identifier.
320 *
321 * @param[out] released is the pointer to an integer variable.  When the
322 *   directive call is successful, the number of released tasks will be stored
323 *   in this variable.
324 *
325 * This directive releases the barrier specified by ``id``.  All tasks waiting
326 * at the barrier will be unblocked.  The number of released tasks will be
327 * returned in ``released``.
328 *
329 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
330 *
331 * @retval ::RTEMS_INVALID_ADDRESS The ``released`` parameter was NULL.
332 *
333 * @retval ::RTEMS_INVALID_ID There was no barrier associated with the
334 *   identifier specified by ``id``.
335 *
336 * @par Constraints
337 * @parblock
338 * The following constraints apply to this directive:
339 *
340 * * The directive may be called from within interrupt context.
341 *
342 * * The directive may be called from within task context.
343 *
344 * * The directive may unblock a task.  This may cause the calling task to be
345 *   preempted.
346 * @endparblock
347 */
348rtems_status_code rtems_barrier_release( rtems_id id, uint32_t *released );
349
350#ifdef __cplusplus
351}
352#endif
353
354#endif /* _RTEMS_RTEMS_BARRIER_H */
Note: See TracBrowser for help on using the repository browser.