1 | /** |
---|
2 | * @file rtems/rtems/barrier.h |
---|
3 | * |
---|
4 | * This include file contains all the constants and structures associated |
---|
5 | * with the Barrier Manager. |
---|
6 | * |
---|
7 | * Directives provided are: |
---|
8 | * |
---|
9 | * - create a barrier |
---|
10 | * - get an ID of a barrier |
---|
11 | * - delete a barrier |
---|
12 | * - wait for a barrier |
---|
13 | * - signal a barrier |
---|
14 | */ |
---|
15 | |
---|
16 | /* COPYRIGHT (c) 1989-2008. |
---|
17 | * On-Line Applications Research Corporation (OAR). |
---|
18 | * |
---|
19 | * The license and distribution terms for this file may be |
---|
20 | * found in the file LICENSE in this distribution or at |
---|
21 | * http://www.rtems.com/license/LICENSE. |
---|
22 | * |
---|
23 | * $Id$ |
---|
24 | */ |
---|
25 | |
---|
26 | #ifndef _RTEMS_RTEMS_BARRIER_H |
---|
27 | #define _RTEMS_RTEMS_BARRIER_H |
---|
28 | |
---|
29 | /** |
---|
30 | * @defgroup ClassicBarrier Barriers |
---|
31 | * |
---|
32 | * @ingroup ClassicRTEMS |
---|
33 | * |
---|
34 | * This encapsulates functionality which XXX |
---|
35 | */ |
---|
36 | /**@{*/ |
---|
37 | |
---|
38 | /** |
---|
39 | * This constant is defined to extern most of the time when using |
---|
40 | * this header file. However by defining it to nothing, the data |
---|
41 | * declared in this header file can be instantiated. This is done |
---|
42 | * in a single per manager file. |
---|
43 | */ |
---|
44 | #ifndef RTEMS_BARRIER_EXTERN |
---|
45 | #define RTEMS_BARRIER_EXTERN extern |
---|
46 | #endif |
---|
47 | |
---|
48 | #ifdef __cplusplus |
---|
49 | extern "C" { |
---|
50 | #endif |
---|
51 | |
---|
52 | #include <rtems/rtems/types.h> |
---|
53 | #include <rtems/rtems/support.h> |
---|
54 | #include <rtems/rtems/attr.h> |
---|
55 | #include <rtems/rtems/status.h> |
---|
56 | #include <rtems/score/object.h> |
---|
57 | #include <rtems/score/corebarrier.h> |
---|
58 | |
---|
59 | /** |
---|
60 | * This type defines the control block used to manage each barrier. |
---|
61 | */ |
---|
62 | typedef struct { |
---|
63 | /** This is used to manage a barrier as an object. */ |
---|
64 | Objects_Control Object; |
---|
65 | /** This is used to specify the attributes of a barrier. */ |
---|
66 | rtems_attribute attribute_set; |
---|
67 | /** This is used to implement the barrier. */ |
---|
68 | CORE_barrier_Control Barrier; |
---|
69 | } Barrier_Control; |
---|
70 | |
---|
71 | /** |
---|
72 | * The following defines the information control block used to manage |
---|
73 | * this class of objects. |
---|
74 | */ |
---|
75 | RTEMS_BARRIER_EXTERN Objects_Information _Barrier_Information; |
---|
76 | |
---|
77 | /** |
---|
78 | * @brief _Barrier_Manager_initialization |
---|
79 | * |
---|
80 | * This routine performs the initialization necessary for this manager. |
---|
81 | */ |
---|
82 | void _Barrier_Manager_initialization(void); |
---|
83 | |
---|
84 | /** |
---|
85 | * @brief rtems_barrier_create |
---|
86 | * |
---|
87 | * This routine implements the rtems_barrier_create directive. The |
---|
88 | * barrier will have the name name. The starting count for |
---|
89 | * the barrier is count. The attribute_set determines if |
---|
90 | * the barrier is global or local and the thread queue |
---|
91 | * discipline. It returns the id of the created barrier in ID. |
---|
92 | * |
---|
93 | * @param[in] name is the name of this barrier instance. |
---|
94 | * @param[in] attribute_set specifies the attributes of this barrier instance. |
---|
95 | * @param[in] maximum_waiters is the maximum number of threads which will |
---|
96 | * be allowed to concurrently wait at the barrier. |
---|
97 | * @param[out] id will contain the id of this barrier. |
---|
98 | * |
---|
99 | * @return a status code indicating success or the reason for failure. |
---|
100 | */ |
---|
101 | rtems_status_code rtems_barrier_create( |
---|
102 | rtems_name name, |
---|
103 | rtems_attribute attribute_set, |
---|
104 | uint32_t maximum_waiters, |
---|
105 | rtems_id *id |
---|
106 | ); |
---|
107 | |
---|
108 | /** |
---|
109 | * @brief rtems_barrier_ident |
---|
110 | * |
---|
111 | * This routine implements the rtems_barrier_ident directive. |
---|
112 | * This directive returns the barrier ID associated with name. |
---|
113 | * If more than one barrier is named name, then the barrier |
---|
114 | * to which the ID belongs is arbitrary. node indicates the |
---|
115 | * extent of the search for the ID of the barrier named name. |
---|
116 | * The search can be limited to a particular node or allowed to |
---|
117 | * encompass all nodes. |
---|
118 | * |
---|
119 | * @param[in] name is the name of this barrier instance. |
---|
120 | * @param[out] id will contain the id of this barrier. |
---|
121 | * |
---|
122 | * @return a status code indicating success or the reason for failure. |
---|
123 | */ |
---|
124 | rtems_status_code rtems_barrier_ident( |
---|
125 | rtems_name name, |
---|
126 | rtems_id *id |
---|
127 | ); |
---|
128 | |
---|
129 | /** |
---|
130 | * @brief rtems_barrier_delete |
---|
131 | * |
---|
132 | * This routine implements the rtems_barrier_delete directive. The |
---|
133 | * barrier indicated by @a id is deleted. |
---|
134 | * |
---|
135 | * @param[in] id indicates the barrier to delete |
---|
136 | * |
---|
137 | * @return a status code indicating success or the reason for failure. |
---|
138 | */ |
---|
139 | rtems_status_code rtems_barrier_delete( |
---|
140 | rtems_id id |
---|
141 | ); |
---|
142 | |
---|
143 | /** |
---|
144 | * @brief rtems_barrier_wait |
---|
145 | * |
---|
146 | * This routine implements the rtems_barrier_wait directive. It |
---|
147 | * attempts to wait at the barrier associated with @a id. The calling task |
---|
148 | * may block waiting for the barrier with an optional timeout of @a timeout |
---|
149 | * clock ticks. |
---|
150 | * |
---|
151 | * @param[in] id indicates the barrier to wait at. |
---|
152 | * @param[in] timeout is the maximum length of time in ticks the calling |
---|
153 | * thread is willing to block. |
---|
154 | * |
---|
155 | * @return a status code indicating success or the reason for failure. |
---|
156 | */ |
---|
157 | rtems_status_code rtems_barrier_wait( |
---|
158 | rtems_id id, |
---|
159 | rtems_interval timeout |
---|
160 | ); |
---|
161 | |
---|
162 | /** |
---|
163 | * @brief rtems_barrier_release |
---|
164 | * |
---|
165 | * This routine implements the rtems_barrier_release directive. It |
---|
166 | * unblocks all of the threads waiting on the barrier associated with |
---|
167 | * @a id. The number of threads unblocked is returned in @a released. |
---|
168 | * |
---|
169 | * |
---|
170 | * @param[in] id indicates the barrier to wait at. |
---|
171 | * @param[out] released will contain the number of threads unblocked. |
---|
172 | * |
---|
173 | * @return a status code indicating success or the reason for failure. |
---|
174 | */ |
---|
175 | rtems_status_code rtems_barrier_release( |
---|
176 | rtems_id id, |
---|
177 | uint32_t *released |
---|
178 | ); |
---|
179 | |
---|
180 | /** |
---|
181 | * @brief Translate SuperCore Barrier Status Code to RTEMS Status Code |
---|
182 | * |
---|
183 | * This function returns a RTEMS status code based on the barrier |
---|
184 | * status code specified. |
---|
185 | * |
---|
186 | * @param[in] the_status is the SuperCore Barrier status to translate. |
---|
187 | * |
---|
188 | * @return a status code indicating success or the reason for failure. |
---|
189 | */ |
---|
190 | rtems_status_code _Barrier_Translate_core_barrier_return_code ( |
---|
191 | CORE_barrier_Status the_status |
---|
192 | ); |
---|
193 | |
---|
194 | #ifndef __RTEMS_APPLICATION__ |
---|
195 | #include <rtems/rtems/barrier.inl> |
---|
196 | #endif |
---|
197 | |
---|
198 | #ifdef __cplusplus |
---|
199 | } |
---|
200 | #endif |
---|
201 | |
---|
202 | /**@}*/ |
---|
203 | |
---|
204 | #endif |
---|
205 | /* end of include file */ |
---|