1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Inlined Routines Associated with the SuperCore RWLock |
---|
5 | * |
---|
6 | * This include file contains all of the inlined routines associated |
---|
7 | * with the SuperCore RWLock. |
---|
8 | */ |
---|
9 | |
---|
10 | /* |
---|
11 | * COPYRIGHT (c) 1989-2008. |
---|
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_CORERWLOCKIMPL_H |
---|
20 | #define _RTEMS_SCORE_CORERWLOCKIMPL_H |
---|
21 | |
---|
22 | #include <rtems/score/corerwlock.h> |
---|
23 | #include <rtems/score/thread.h> |
---|
24 | #include <rtems/score/threadqimpl.h> |
---|
25 | #include <rtems/score/watchdog.h> |
---|
26 | |
---|
27 | #ifdef __cplusplus |
---|
28 | extern "C" { |
---|
29 | #endif |
---|
30 | |
---|
31 | /** |
---|
32 | * @addtogroup ScoreRWLock |
---|
33 | */ |
---|
34 | /**@{**/ |
---|
35 | |
---|
36 | #define CORE_RWLOCK_TQ_OPERATIONS &_Thread_queue_Operations_FIFO |
---|
37 | |
---|
38 | /** |
---|
39 | * The following type defines the callout which the API provides |
---|
40 | * to support global/multiprocessor operations on RWLocks. |
---|
41 | */ |
---|
42 | typedef void ( *CORE_RWLock_API_mp_support_callout )( |
---|
43 | Thread_Control *, |
---|
44 | Objects_Id |
---|
45 | ); |
---|
46 | |
---|
47 | /** |
---|
48 | * Core RWLock handler return statuses. |
---|
49 | */ |
---|
50 | typedef enum { |
---|
51 | /** This status indicates that the operation completed successfully. */ |
---|
52 | CORE_RWLOCK_SUCCESSFUL, |
---|
53 | /** This status indicates that the thread was blocked waiting for an */ |
---|
54 | CORE_RWLOCK_WAS_DELETED, |
---|
55 | /** This status indicates that the rwlock was not immediately available. */ |
---|
56 | CORE_RWLOCK_UNAVAILABLE, |
---|
57 | /** This status indicates that the calling task was willing to block |
---|
58 | * but the operation was unable to complete within the time allotted |
---|
59 | * because the resource never became available. |
---|
60 | */ |
---|
61 | CORE_RWLOCK_TIMEOUT |
---|
62 | } CORE_RWLock_Status; |
---|
63 | |
---|
64 | /** This is the last status value. |
---|
65 | */ |
---|
66 | #define CORE_RWLOCK_STATUS_LAST CORE_RWLOCK_TIMEOUT |
---|
67 | |
---|
68 | /** |
---|
69 | * This is used to denote that a thread is blocking waiting for |
---|
70 | * read-only access to the RWLock. |
---|
71 | */ |
---|
72 | #define CORE_RWLOCK_THREAD_WAITING_FOR_READ 0 |
---|
73 | |
---|
74 | /** |
---|
75 | * This is used to denote that a thread is blocking waiting for |
---|
76 | * write-exclusive access to the RWLock. |
---|
77 | */ |
---|
78 | #define CORE_RWLOCK_THREAD_WAITING_FOR_WRITE 1 |
---|
79 | |
---|
80 | /** |
---|
81 | * @brief Initialize a RWlock. |
---|
82 | * |
---|
83 | * This routine initializes the RWLock based on the parameters passed. |
---|
84 | * |
---|
85 | * @param[in] the_rwlock is the RWLock to initialize |
---|
86 | * @param[in] the_rwlock_attributes define the behavior of this instance |
---|
87 | */ |
---|
88 | void _CORE_RWLock_Initialize( |
---|
89 | CORE_RWLock_Control *the_rwlock, |
---|
90 | CORE_RWLock_Attributes *the_rwlock_attributes |
---|
91 | ); |
---|
92 | |
---|
93 | RTEMS_INLINE_ROUTINE void _CORE_RWLock_Destroy( |
---|
94 | CORE_RWLock_Control *the_rwlock |
---|
95 | ) |
---|
96 | { |
---|
97 | _Thread_queue_Destroy( &the_rwlock->Wait_queue ); |
---|
98 | } |
---|
99 | |
---|
100 | /** |
---|
101 | * @brief Obtain RWLock for reading. |
---|
102 | * |
---|
103 | * This routine attempts to obtain the RWLock for read access. |
---|
104 | * |
---|
105 | * @param[in] the_rwlock is the RWLock to wait for |
---|
106 | * @param[in] id is the id of the object being waited upon |
---|
107 | * @param[in] wait is true if the calling thread is willing to wait |
---|
108 | * @param[in] timeout is the number of ticks the calling thread is willing |
---|
109 | * to wait if @a wait is true. |
---|
110 | * @param[in] api_rwlock_mp_support is the routine to invoke if the |
---|
111 | * thread unblocked is remote |
---|
112 | * |
---|
113 | * @note Status is returned via the thread control block. |
---|
114 | */ |
---|
115 | |
---|
116 | void _CORE_RWLock_Obtain_for_reading( |
---|
117 | CORE_RWLock_Control *the_rwlock, |
---|
118 | Thread_Control *executing, |
---|
119 | Objects_Id id, |
---|
120 | bool wait, |
---|
121 | Watchdog_Interval timeout, |
---|
122 | CORE_RWLock_API_mp_support_callout api_rwlock_mp_support |
---|
123 | ); |
---|
124 | |
---|
125 | /** |
---|
126 | * @brief Obtain RWLock for writing. |
---|
127 | * |
---|
128 | * This routine attempts to obtain the RWLock for write exclusive access. |
---|
129 | * |
---|
130 | * @param[in] the_rwlock is the RWLock to wait for |
---|
131 | * @param[in] id is the id of the object being waited upon |
---|
132 | * @param[in] wait is true if the calling thread is willing to wait |
---|
133 | * @param[in] timeout is the number of ticks the calling thread is willing |
---|
134 | * to wait if @a wait is true. |
---|
135 | * @param[in] api_rwlock_mp_support is the routine to invoke if the |
---|
136 | * thread unblocked is remote |
---|
137 | * |
---|
138 | * @note Status is returned via the thread control block. |
---|
139 | */ |
---|
140 | void _CORE_RWLock_Obtain_for_writing( |
---|
141 | CORE_RWLock_Control *the_rwlock, |
---|
142 | Thread_Control *executing, |
---|
143 | Objects_Id id, |
---|
144 | bool wait, |
---|
145 | Watchdog_Interval timeout, |
---|
146 | CORE_RWLock_API_mp_support_callout api_rwlock_mp_support |
---|
147 | ); |
---|
148 | |
---|
149 | /** |
---|
150 | * @brief Release the RWLock. |
---|
151 | * |
---|
152 | * This routine manually releases @a the_rwlock. All of the threads waiting |
---|
153 | * for the RWLock will be readied. |
---|
154 | * |
---|
155 | * @param[in] the_rwlock is the RWLock to surrender |
---|
156 | * |
---|
157 | * @retval Status is returned to indicate successful or failure. |
---|
158 | */ |
---|
159 | CORE_RWLock_Status _CORE_RWLock_Release( |
---|
160 | CORE_RWLock_Control *the_rwlock, |
---|
161 | Thread_Control *executing |
---|
162 | ); |
---|
163 | |
---|
164 | /** |
---|
165 | * This routine assists in the deletion of a RWLock by flushing the |
---|
166 | * associated wait queue. |
---|
167 | * |
---|
168 | * @param[in] _the_rwlock is the RWLock to flush |
---|
169 | * @param[in] _remote_extract_callout is the routine to invoke if the |
---|
170 | * thread unblocked is remote |
---|
171 | * @param[in] _status is the status to be returned to the unblocked thread |
---|
172 | */ |
---|
173 | #define _CORE_RWLock_Flush( _the_rwlock, _remote_extract_callout, _status) \ |
---|
174 | _Thread_queue_Flush( \ |
---|
175 | &((_the_rwlock)->Wait_queue), \ |
---|
176 | (_remote_extract_callout), \ |
---|
177 | (_status) \ |
---|
178 | ) |
---|
179 | |
---|
180 | /** |
---|
181 | * This method is used to initialize core rwlock attributes. |
---|
182 | * |
---|
183 | * @param[in] the_attributes pointer to the attributes to initialize. |
---|
184 | */ |
---|
185 | RTEMS_INLINE_ROUTINE void _CORE_RWLock_Initialize_attributes( |
---|
186 | CORE_RWLock_Attributes *the_attributes |
---|
187 | ) |
---|
188 | { |
---|
189 | the_attributes->XXX = 0; |
---|
190 | } |
---|
191 | |
---|
192 | /** @} */ |
---|
193 | |
---|
194 | #ifdef __cplusplus |
---|
195 | } |
---|
196 | #endif |
---|
197 | |
---|
198 | #endif |
---|
199 | /* end of include file */ |
---|