37#ifndef _RTEMS_THREAD_H
38#define _RTEMS_THREAD_H
47int _Semaphore_Wait_timed_ticks(
struct _Semaphore_Control *, __uint32_t);
50int _Semaphore_Try_wait(
struct _Semaphore_Control *);
53void _Semaphore_Post_binary(
struct _Semaphore_Control *);
55typedef struct _Mutex_Control rtems_mutex;
67#define RTEMS_MUTEX_INITIALIZER( name ) _MUTEX_NAMED_INITIALIZER( name )
69static __inline
void rtems_mutex_init( rtems_mutex *
mutex,
const char *name )
71 _Mutex_Initialize_named(
mutex, name );
74static __inline
const char *rtems_mutex_get_name(
const rtems_mutex *
mutex )
76 return mutex->_Queue._name;
79static __inline
void rtems_mutex_set_name( rtems_mutex *
mutex,
const char *name )
81 mutex->_Queue._name = name;
84static __inline
void rtems_mutex_lock( rtems_mutex *
mutex )
86 _Mutex_Acquire(
mutex );
89static __inline
int rtems_mutex_try_lock( rtems_mutex *
mutex )
91 return _Mutex_Try_acquire(
mutex );
94static __inline
void rtems_mutex_unlock( rtems_mutex *
mutex )
96 _Mutex_Release(
mutex );
99static __inline
void rtems_mutex_destroy( rtems_mutex *
mutex )
101 _Mutex_Destroy(
mutex );
104typedef struct _Mutex_recursive_Control rtems_recursive_mutex;
106#define RTEMS_RECURSIVE_MUTEX_INITIALIZER( name ) \
107 _MUTEX_RECURSIVE_NAMED_INITIALIZER( name )
109static __inline
void rtems_recursive_mutex_init(
110 rtems_recursive_mutex *
mutex,
const char *name
113 _Mutex_recursive_Initialize_named(
mutex, name );
116static __inline
const char *rtems_recursive_mutex_get_name(
117 const rtems_recursive_mutex *
mutex
120 return mutex->_Mutex._Queue._name;
123static __inline
void rtems_recursive_mutex_set_name(
124 rtems_recursive_mutex *
mutex,
const char *name
127 mutex->_Mutex._Queue._name = name;
130static __inline
void rtems_recursive_mutex_lock(
131 rtems_recursive_mutex *
mutex
134 _Mutex_recursive_Acquire(
mutex );
137static __inline
int rtems_recursive_mutex_try_lock(
138 rtems_recursive_mutex *
mutex
141 return _Mutex_recursive_Try_acquire(
mutex );
144static __inline
void rtems_recursive_mutex_unlock(
145 rtems_recursive_mutex *
mutex
148 _Mutex_recursive_Release(
mutex );
151static __inline
void rtems_recursive_mutex_destroy(
152 rtems_recursive_mutex *
mutex
155 _Mutex_recursive_Destroy(
mutex );
158typedef struct _Condition_Control rtems_condition_variable;
160#define RTEMS_CONDITION_VARIABLE_INITIALIZER( name ) \
161 _CONDITION_NAMED_INITIALIZER( name )
163static __inline
void rtems_condition_variable_init(
164 rtems_condition_variable *condition_variable,
168 _Condition_Initialize_named( condition_variable, name );
171static __inline
const char *rtems_condition_variable_get_name(
172 const rtems_condition_variable *condition_variable
175 return condition_variable->_Queue._name;
178static __inline
void rtems_condition_variable_set_name(
179 rtems_condition_variable *condition_variable,
183 condition_variable->_Queue._name = name;
186static __inline
void rtems_condition_variable_wait(
187 rtems_condition_variable *condition_variable,
191 _Condition_Wait( condition_variable,
mutex );
194static __inline
void rtems_condition_variable_signal(
195 rtems_condition_variable *condition_variable
198 _Condition_Signal( condition_variable );
201static __inline
void rtems_condition_variable_broadcast(
202 rtems_condition_variable *condition_variable
205 _Condition_Broadcast( condition_variable );
208static __inline
void rtems_condition_variable_destroy(
209 rtems_condition_variable *condition_variable
212 _Condition_Destroy( condition_variable );
215typedef struct _Semaphore_Control rtems_counting_semaphore;
217#define RTEMS_COUNTING_SEMAPHORE_INITIALIZER( name, value ) \
218 _SEMAPHORE_NAMED_INITIALIZER( name, value )
220static __inline
void rtems_counting_semaphore_init(
221 rtems_counting_semaphore *counting_semaphore,
226 _Semaphore_Initialize_named( counting_semaphore, name, value );
229static __inline
const char *rtems_counting_semaphore_get_name(
230 const rtems_counting_semaphore *counting_semaphore
233 return counting_semaphore->_Queue._name;
236static __inline
void rtems_counting_semaphore_set_name(
237 rtems_counting_semaphore *counting_semaphore,
241 counting_semaphore->_Queue._name = name;
244static __inline
void rtems_counting_semaphore_wait(
245 rtems_counting_semaphore *counting_semaphore
248 _Semaphore_Wait( counting_semaphore );
251static __inline
int rtems_counting_semaphore_wait_timed_ticks(
252 rtems_counting_semaphore *counting_semaphore,
256 return _Semaphore_Wait_timed_ticks( counting_semaphore, ticks );
259static __inline
int rtems_counting_semaphore_try_wait(
260 rtems_counting_semaphore *counting_semaphore
263 return _Semaphore_Try_wait( counting_semaphore );
266static __inline
void rtems_counting_semaphore_post(
267 rtems_counting_semaphore *counting_semaphore
270 _Semaphore_Post( counting_semaphore );
273static __inline
void rtems_counting_semaphore_destroy(
274 rtems_counting_semaphore *counting_semaphore
277 _Semaphore_Destroy( counting_semaphore );
281 struct _Semaphore_Control Semaphore;
284#define RTEMS_BINARY_SEMAPHORE_INITIALIZER( name ) \
285 { _SEMAPHORE_NAMED_INITIALIZER( name, 0 ) }
287static __inline
void rtems_binary_semaphore_init(
292 _Semaphore_Initialize_named( &binary_semaphore->Semaphore, name, 0 );
295static __inline
const char *rtems_binary_semaphore_get_name(
299 return binary_semaphore->Semaphore._Queue._name;
302static __inline
void rtems_binary_semaphore_set_name(
307 binary_semaphore->Semaphore._Queue._name = name;
310static __inline
void rtems_binary_semaphore_wait(
314 _Semaphore_Wait( &binary_semaphore->Semaphore );
317static __inline
int rtems_binary_semaphore_wait_timed_ticks(
322 return _Semaphore_Wait_timed_ticks( &binary_semaphore->Semaphore, ticks );
325static __inline
int rtems_binary_semaphore_try_wait(
329 return _Semaphore_Try_wait( &binary_semaphore->Semaphore );
332static __inline
void rtems_binary_semaphore_post(
336 _Semaphore_Post_binary( &binary_semaphore->Semaphore );
339static __inline
void rtems_binary_semaphore_destroy(
343 _Semaphore_Destroy( &binary_semaphore->Semaphore );