15 #ifndef _RTEMS_THREAD_H 16 #define _RTEMS_THREAD_H 25 int _Semaphore_Wait_timed_ticks(
struct _Semaphore_Control *, __uint32_t);
28 int _Semaphore_Try_wait(
struct _Semaphore_Control *);
31 void _Semaphore_Post_binary(
struct _Semaphore_Control *);
33 typedef struct _Mutex_Control rtems_mutex;
35 #define RTEMS_MUTEX_INITIALIZER( name ) _MUTEX_NAMED_INITIALIZER( name ) 37 static __inline
void rtems_mutex_init( rtems_mutex *mutex,
const char *name )
39 _Mutex_Initialize_named( mutex, name );
42 static __inline
const char *rtems_mutex_get_name(
const rtems_mutex *mutex )
44 return mutex->_Queue._name;
47 static __inline
void rtems_mutex_set_name( rtems_mutex *mutex,
const char *name )
49 mutex->_Queue._name = name;
52 static __inline
void rtems_mutex_lock( rtems_mutex *mutex )
54 _Mutex_Acquire( mutex );
57 static __inline
void rtems_mutex_unlock( rtems_mutex *mutex )
59 _Mutex_Release( mutex );
62 static __inline
void rtems_mutex_destroy( rtems_mutex *mutex )
64 _Mutex_Destroy( mutex );
67 typedef struct _Mutex_recursive_Control rtems_recursive_mutex;
69 #define RTEMS_RECURSIVE_MUTEX_INITIALIZER( name ) \ 70 _MUTEX_RECURSIVE_NAMED_INITIALIZER( name ) 72 static __inline
void rtems_recursive_mutex_init(
73 rtems_recursive_mutex *mutex,
const char *name
76 _Mutex_recursive_Initialize_named( mutex, name );
79 static __inline
const char *rtems_recursive_mutex_get_name(
80 const rtems_recursive_mutex *mutex
83 return mutex->_Mutex._Queue._name;
86 static __inline
void rtems_recursive_mutex_set_name(
87 rtems_recursive_mutex *mutex,
const char *name
90 mutex->_Mutex._Queue._name = name;
93 static __inline
void rtems_recursive_mutex_lock(
94 rtems_recursive_mutex *mutex
97 _Mutex_recursive_Acquire( mutex );
100 static __inline
void rtems_recursive_mutex_unlock(
101 rtems_recursive_mutex *mutex
104 _Mutex_recursive_Release( mutex );
107 static __inline
void rtems_recursive_mutex_destroy(
108 rtems_recursive_mutex *mutex
111 _Mutex_recursive_Destroy( mutex );
114 typedef struct _Condition_Control rtems_condition_variable;
116 #define RTEMS_CONDITION_VARIABLE_INITIALIZER( name ) \ 117 _CONDITION_NAMED_INITIALIZER( name ) 119 static __inline
void rtems_condition_variable_init(
120 rtems_condition_variable *condition_variable,
124 _Condition_Initialize_named( condition_variable, name );
127 static __inline
const char *rtems_condition_variable_get_name(
128 const rtems_condition_variable *condition_variable
131 return condition_variable->_Queue._name;
134 static __inline
void rtems_condition_variable_set_name(
135 rtems_condition_variable *condition_variable,
139 condition_variable->_Queue._name = name;
142 static __inline
void rtems_condition_variable_wait(
143 rtems_condition_variable *condition_variable,
147 _Condition_Wait( condition_variable, mutex );
150 static __inline
void rtems_condition_variable_signal(
151 rtems_condition_variable *condition_variable
154 _Condition_Broadcast( condition_variable );
157 static __inline
void rtems_condition_variable_broadcast(
158 rtems_condition_variable *condition_variable
161 _Condition_Broadcast( condition_variable );
164 static __inline
void rtems_condition_variable_destroy(
165 rtems_condition_variable *condition_variable
168 _Condition_Destroy( condition_variable );
171 typedef struct _Semaphore_Control rtems_counting_semaphore;
173 #define RTEMS_COUNTING_SEMAPHORE_INITIALIZER( name, value ) \ 174 _SEMAPHORE_NAMED_INITIALIZER( name, value ) 176 static __inline
void rtems_counting_semaphore_init(
177 rtems_counting_semaphore *counting_semaphore,
182 _Semaphore_Initialize_named( counting_semaphore, name, value );
185 static __inline
const char *rtems_counting_semaphore_get_name(
186 const rtems_counting_semaphore *counting_semaphore
189 return counting_semaphore->_Queue._name;
192 static __inline
void rtems_counting_semaphore_set_name(
193 rtems_counting_semaphore *counting_semaphore,
197 counting_semaphore->_Queue._name = name;
200 static __inline
void rtems_counting_semaphore_wait(
201 rtems_counting_semaphore *counting_semaphore
204 _Semaphore_Wait( counting_semaphore );
207 static __inline
void rtems_counting_semaphore_post(
208 rtems_counting_semaphore *counting_semaphore
211 _Semaphore_Post( counting_semaphore );
214 static __inline
void rtems_counting_semaphore_destroy(
215 rtems_counting_semaphore *counting_semaphore
218 _Semaphore_Destroy( counting_semaphore );
222 struct _Semaphore_Control Semaphore;
225 #define RTEMS_BINARY_SEMAPHORE_INITIALIZER( name ) \ 226 { _SEMAPHORE_NAMED_INITIALIZER( name, 0 ) } 228 static __inline
void rtems_binary_semaphore_init(
233 _Semaphore_Initialize_named( &binary_semaphore->Semaphore, name, 0 );
236 static __inline
const char *rtems_binary_semaphore_get_name(
240 return binary_semaphore->Semaphore._Queue._name;
243 static __inline
void rtems_binary_semaphore_set_name(
248 binary_semaphore->Semaphore._Queue._name = name;
251 static __inline
void rtems_binary_semaphore_wait(
255 _Semaphore_Wait( &binary_semaphore->Semaphore );
258 static __inline
int rtems_binary_semaphore_wait_timed_ticks(
263 return _Semaphore_Wait_timed_ticks( &binary_semaphore->Semaphore, ticks );
266 static __inline
int rtems_binary_semaphore_try_wait(
270 return _Semaphore_Try_wait( &binary_semaphore->Semaphore );
273 static __inline
void rtems_binary_semaphore_post(
277 _Semaphore_Post_binary( &binary_semaphore->Semaphore );
280 static __inline
void rtems_binary_semaphore_destroy(
284 _Semaphore_Destroy( &binary_semaphore->Semaphore );