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/watchdog.h> |
---|
25 | |
---|
26 | #ifdef __cplusplus |
---|
27 | extern "C" { |
---|
28 | #endif |
---|
29 | |
---|
30 | /** |
---|
31 | * @addtogroup ScoreBarrier |
---|
32 | */ |
---|
33 | /**@{**/ |
---|
34 | |
---|
35 | /** |
---|
36 | * Core Barrier handler return statuses. |
---|
37 | */ |
---|
38 | typedef enum { |
---|
39 | /** This status indicates that the operation completed successfully. */ |
---|
40 | CORE_BARRIER_STATUS_SUCCESSFUL, |
---|
41 | /** This status indicates that the barrier is configured for automatic |
---|
42 | * release and the caller tripped the automatic release. The caller |
---|
43 | * thus did not block. |
---|
44 | */ |
---|
45 | CORE_BARRIER_STATUS_AUTOMATICALLY_RELEASED, |
---|
46 | /** This status indicates that the thread was blocked waiting for an |
---|
47 | * operation to complete and the barrier was deleted. |
---|
48 | */ |
---|
49 | CORE_BARRIER_WAS_DELETED, |
---|
50 | /** This status indicates that the calling task was willing to block |
---|
51 | * but the operation was unable to complete within the time allotted |
---|
52 | * because the resource never became available. |
---|
53 | */ |
---|
54 | CORE_BARRIER_TIMEOUT |
---|
55 | } CORE_barrier_Status; |
---|
56 | |
---|
57 | /** |
---|
58 | * @brief Core barrier last status value. |
---|
59 | * |
---|
60 | * This is the last status value. |
---|
61 | */ |
---|
62 | #define CORE_BARRIER_STATUS_LAST CORE_BARRIER_TIMEOUT |
---|
63 | |
---|
64 | /** |
---|
65 | * The following type defines the callout which the API provides |
---|
66 | * to support global/multiprocessor operations on barriers. |
---|
67 | */ |
---|
68 | typedef void ( *CORE_barrier_API_mp_support_callout )( |
---|
69 | Thread_Control *, |
---|
70 | Objects_Id |
---|
71 | ); |
---|
72 | |
---|
73 | /** |
---|
74 | * @brief Initialize core barrier. |
---|
75 | * |
---|
76 | * This routine initializes the barrier based on the parameters passed. |
---|
77 | * |
---|
78 | * @param[in] the_barrier is the barrier to initialize |
---|
79 | * @param[in] the_barrier_attributes define the behavior of this instance |
---|
80 | */ |
---|
81 | void _CORE_barrier_Initialize( |
---|
82 | CORE_barrier_Control *the_barrier, |
---|
83 | CORE_barrier_Attributes *the_barrier_attributes |
---|
84 | ); |
---|
85 | |
---|
86 | /** |
---|
87 | * @brief Wait for the barrier. |
---|
88 | * |
---|
89 | * This routine wait for the barrier to be released. If the barrier |
---|
90 | * is set to automatic and this is the appropriate thread, then it returns |
---|
91 | * immediately. Otherwise, the calling thread is blocked until the barrier |
---|
92 | * is released. |
---|
93 | * |
---|
94 | * @param[in] the_barrier is the barrier to wait for |
---|
95 | * @param[in,out] executing The currently executing thread. |
---|
96 | * @param[in] id is the id of the object being waited upon |
---|
97 | * @param[in] wait is true if the calling thread is willing to wait |
---|
98 | * @param[in] timeout is the number of ticks the calling thread is willing |
---|
99 | * to wait if @a wait is true. |
---|
100 | * @param[in] api_barrier_mp_support is the routine to invoke if the |
---|
101 | * thread unblocked is remote |
---|
102 | * |
---|
103 | * @note Status is returned via the thread control block. |
---|
104 | */ |
---|
105 | void _CORE_barrier_Wait( |
---|
106 | CORE_barrier_Control *the_barrier, |
---|
107 | Thread_Control *executing, |
---|
108 | Objects_Id id, |
---|
109 | bool wait, |
---|
110 | Watchdog_Interval timeout, |
---|
111 | CORE_barrier_API_mp_support_callout api_barrier_mp_support |
---|
112 | ); |
---|
113 | |
---|
114 | /** |
---|
115 | * @brief Manually release the barrier. |
---|
116 | * |
---|
117 | * This routine manually releases the barrier. All of the threads waiting |
---|
118 | * for the barrier will be readied. |
---|
119 | * |
---|
120 | * @param[in] the_barrier is the barrier to surrender |
---|
121 | * @param[in] id is the id of the object for a remote unblock |
---|
122 | * @param[in] api_barrier_mp_support is the routine to invoke if the |
---|
123 | * thread unblocked is remote |
---|
124 | * |
---|
125 | * @retval the number of unblocked threads |
---|
126 | */ |
---|
127 | uint32_t _CORE_barrier_Release( |
---|
128 | CORE_barrier_Control *the_barrier, |
---|
129 | Objects_Id id, |
---|
130 | CORE_barrier_API_mp_support_callout api_barrier_mp_support |
---|
131 | ); |
---|
132 | |
---|
133 | /** |
---|
134 | * This routine assists in the deletion of a barrier by flushing the |
---|
135 | * associated wait queue. |
---|
136 | * |
---|
137 | * @param[in] _the_barrier is the barrier to flush |
---|
138 | * @param[in] _remote_extract_callout is the routine to invoke if the |
---|
139 | * thread unblocked is remote |
---|
140 | * @param[in] _status is the status to be returned to the unblocked thread |
---|
141 | */ |
---|
142 | #define _CORE_barrier_Flush( _the_barrier, _remote_extract_callout, _status) \ |
---|
143 | _Thread_queue_Flush( \ |
---|
144 | &((_the_barrier)->Wait_queue), \ |
---|
145 | (_remote_extract_callout), \ |
---|
146 | (_status) \ |
---|
147 | ) |
---|
148 | |
---|
149 | /** |
---|
150 | * This function returns true if the automatic release attribute is |
---|
151 | * enabled in the @a attribute_set and false otherwise. |
---|
152 | * |
---|
153 | * @param[in] the_attribute is the attribute set to test |
---|
154 | * |
---|
155 | * @return true if the priority attribute is enabled |
---|
156 | */ |
---|
157 | RTEMS_INLINE_ROUTINE bool _CORE_barrier_Is_automatic( |
---|
158 | CORE_barrier_Attributes *the_attribute |
---|
159 | ) |
---|
160 | { |
---|
161 | return |
---|
162 | (the_attribute->discipline == CORE_BARRIER_AUTOMATIC_RELEASE); |
---|
163 | } |
---|
164 | |
---|
165 | /** |
---|
166 | * This routine returns the number of threads currently waiting at the barrier. |
---|
167 | * |
---|
168 | * @param[in] the_barrier is the barrier to obtain the number of blocked |
---|
169 | * threads for |
---|
170 | * @return the current count of this barrier |
---|
171 | */ |
---|
172 | RTEMS_INLINE_ROUTINE uint32_t _CORE_barrier_Get_number_of_waiting_threads( |
---|
173 | CORE_barrier_Control *the_barrier |
---|
174 | ) |
---|
175 | { |
---|
176 | return the_barrier->number_of_waiting_threads; |
---|
177 | } |
---|
178 | |
---|
179 | /** @} */ |
---|
180 | |
---|
181 | #ifdef __cplusplus |
---|
182 | } |
---|
183 | #endif |
---|
184 | |
---|
185 | #endif |
---|
186 | /* end of include file */ |
---|