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
void rtems_counting_semaphore_post(
252 rtems_counting_semaphore *counting_semaphore
255 _Semaphore_Post( counting_semaphore );
258static __inline
void rtems_counting_semaphore_destroy(
259 rtems_counting_semaphore *counting_semaphore
262 _Semaphore_Destroy( counting_semaphore );
266 struct _Semaphore_Control Semaphore;
269#define RTEMS_BINARY_SEMAPHORE_INITIALIZER( name ) \
270 { _SEMAPHORE_NAMED_INITIALIZER( name, 0 ) }
272static __inline
void rtems_binary_semaphore_init(
277 _Semaphore_Initialize_named( &binary_semaphore->Semaphore, name, 0 );
280static __inline
const char *rtems_binary_semaphore_get_name(
284 return binary_semaphore->Semaphore._Queue._name;
287static __inline
void rtems_binary_semaphore_set_name(
292 binary_semaphore->Semaphore._Queue._name = name;
295static __inline
void rtems_binary_semaphore_wait(
299 _Semaphore_Wait( &binary_semaphore->Semaphore );
302static __inline
int rtems_binary_semaphore_wait_timed_ticks(
307 return _Semaphore_Wait_timed_ticks( &binary_semaphore->Semaphore, ticks );
310static __inline
int rtems_binary_semaphore_try_wait(
314 return _Semaphore_Try_wait( &binary_semaphore->Semaphore );
317static __inline
void rtems_binary_semaphore_post(
321 _Semaphore_Post_binary( &binary_semaphore->Semaphore );
324static __inline
void rtems_binary_semaphore_destroy(
328 _Semaphore_Destroy( &binary_semaphore->Semaphore );