18 #ifndef _RTEMS_SCORE_COREMUTEXIMPL_H 19 #define _RTEMS_SCORE_COREMUTEXIMPL_H 24 #include <rtems/score/status.h> 37 #define CORE_MUTEX_TQ_OPERATIONS &_Thread_queue_Operations_priority 39 #define CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS \ 40 &_Thread_queue_Operations_priority_inherit 51 _Thread_queue_Destroy( &the_mutex->
Wait_queue );
59 _Thread_queue_Acquire_critical( &the_mutex->
Wait_queue, queue_context );
67 _Thread_queue_Release( &the_mutex->
Wait_queue, queue_context );
92 return _CORE_mutex_Get_owner( the_mutex ) !=
NULL;
95 Status_Control _CORE_mutex_Seize_slow(
116 return _CORE_mutex_Get_owner( the_mutex ) == the_thread;
123 _CORE_mutex_Initialize( &the_mutex->
Mutex );
132 return STATUS_SUCCESSFUL;
146 _CORE_mutex_Acquire_critical( &the_mutex->
Mutex, queue_context );
148 owner = _CORE_mutex_Get_owner( &the_mutex->
Mutex );
150 if ( owner ==
NULL ) {
151 _CORE_mutex_Set_owner( &the_mutex->
Mutex, executing );
152 _Thread_Resource_count_increment( executing );
153 _CORE_mutex_Release( &the_mutex->
Mutex, queue_context );
154 return STATUS_SUCCESSFUL;
157 if ( owner == executing ) {
158 Status_Control status;
160 status = ( *nested )( the_mutex );
161 _CORE_mutex_Release( &the_mutex->
Mutex, queue_context );
165 return _CORE_mutex_Seize_slow(
181 unsigned int nest_level;
184 _CORE_mutex_Acquire_critical( &the_mutex->
Mutex, queue_context );
186 if ( !_CORE_mutex_Is_owner( &the_mutex->
Mutex, executing ) ) {
187 _CORE_mutex_Release( &the_mutex->
Mutex, queue_context );
188 return STATUS_NOT_OWNER;
193 if ( nest_level > 0 ) {
195 _CORE_mutex_Release( &the_mutex->
Mutex, queue_context );
196 return STATUS_SUCCESSFUL;
199 _Thread_Resource_count_decrement( executing );
200 _CORE_mutex_Set_owner( &the_mutex->
Mutex,
NULL );
204 if ( heads ==
NULL ) {
205 _CORE_mutex_Release( &the_mutex->
Mutex, queue_context );
206 return STATUS_SUCCESSFUL;
216 return STATUS_SUCCESSFUL;
225 _CORE_recursive_mutex_Initialize( &the_mutex->
Recursive );
226 _Priority_Node_initialize( &the_mutex->
Priority_ceiling, priority_ceiling );
227 #if defined(RTEMS_SMP) 228 the_mutex->scheduler = scheduler;
233 _CORE_ceiling_mutex_Get_scheduler(
237 #if defined(RTEMS_SMP) 238 return the_mutex->scheduler;
254 if ( owner !=
NULL ) {
288 scheduler_node = _Thread_Scheduler_get_home_node( owner );
291 _Priority_Get_priority( &scheduler_node->
Wait.Priority )
295 _CORE_mutex_Release( &the_mutex->
Recursive.
Mutex, queue_context );
296 return STATUS_MUTEX_CEILING_VIOLATED;
300 _Thread_Resource_count_increment( owner );
308 cpu_self = _Thread_queue_Dispatch_disable( queue_context );
309 _CORE_mutex_Release( &the_mutex->
Recursive.
Mutex, queue_context );
312 return STATUS_SUCCESSFUL;
325 _CORE_mutex_Acquire_critical( &the_mutex->
Recursive.
Mutex, queue_context );
329 if ( owner ==
NULL ) {
330 #if defined(RTEMS_SMP) 332 _Thread_Scheduler_get_home( executing )
333 != _CORE_ceiling_mutex_Get_scheduler( the_mutex )
335 _CORE_mutex_Release( &the_mutex->
Recursive.
Mutex, queue_context );
336 return STATUS_NOT_DEFINED;
340 _Thread_queue_Context_clear_priority_updates( queue_context );
341 return _CORE_ceiling_mutex_Set_owner(
348 if ( owner == executing ) {
349 Status_Control status;
351 status = ( *nested )( &the_mutex->
Recursive );
352 _CORE_mutex_Release( &the_mutex->
Recursive.
Mutex, queue_context );
356 return _CORE_mutex_Seize_slow(
358 CORE_MUTEX_TQ_OPERATIONS,
371 unsigned int nest_level;
376 _CORE_mutex_Acquire_critical( &the_mutex->
Recursive.
Mutex, queue_context );
378 if ( !_CORE_mutex_Is_owner( &the_mutex->
Recursive.
Mutex, executing ) ) {
379 _CORE_mutex_Release( &the_mutex->
Recursive.
Mutex, queue_context );
380 return STATUS_NOT_OWNER;
385 if ( nest_level > 0 ) {
387 _CORE_mutex_Release( &the_mutex->
Recursive.
Mutex, queue_context );
388 return STATUS_SUCCESSFUL;
391 _Thread_Resource_count_decrement( executing );
393 _Thread_queue_Context_clear_priority_updates( queue_context );
404 CORE_MUTEX_TQ_OPERATIONS
412 if ( new_owner !=
NULL ) {
413 #if defined(RTEMS_MULTIPROCESSING) 417 _Thread_Resource_count_increment( new_owner );
427 CORE_MUTEX_TQ_OPERATIONS,
432 _CORE_mutex_Release( &the_mutex->
Recursive.
Mutex, queue_context );
437 return STATUS_SUCCESSFUL;
Priority_Node Priority_ceiling
The priority ceiling node for the mutex owner.
Definition: coremutex.h:87
Thread_Control * owner
The thread queue owner.
Definition: threadq.h:426
void _Thread_queue_Object_initialize(Thread_queue_Control *the_thread_queue)
Initializes a thread queue embedded in an object with identifier.
Definition: threadq.c:148
RTEMS_INLINE_ROUTINE void _Thread_Priority_change(Thread_Control *the_thread, Priority_Node *priority_node, Priority_Control new_priority, bool prepend_it, Thread_queue_Context *queue_context)
Changes the thread priority value of the specified thread priority node in the corresponding thread p...
Definition: threadimpl.h:499
Thread_queue_Control Wait_queue
The thread queue of this mutex.
Definition: coremutex.h:57
void _Thread_Priority_update(Thread_queue_Context *queue_context)
Adds a priority node to the corresponding thread priority aggregation.
Definition: threadchangepriority.c:339
RTEMS_INLINE_ROUTINE Thread_Control * _Thread_queue_First_locked(Thread_queue_Control *the_thread_queue, const Thread_queue_Operations *operations)
Returns the first thread on the thread queue if it exists, otherwise NULL.
Definition: threadqimpl.h:971
Thread queue context for the thread queue methods.
Definition: threadq.h:193
unsigned int nest_level
The nest level in case of a recursive seize.
Definition: coremutex.h:72
void _Thread_Priority_add(Thread_Control *the_thread, Priority_Node *priority_node, Thread_queue_Context *queue_context)
Adds the specified thread priority node to the corresponding thread priority aggregation.
Definition: threadchangepriority.c:277
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:65
CORE_recursive_mutex_Control Recursive
The plain recursive mutex.
Definition: coremutex.h:82
Inlined Routines Associated with the Manipulation of the Scheduler.
Priority_Control priority
The priority value of this node.
Definition: priority.h:106
void _Thread_queue_Surrender(Thread_queue_Queue *queue, Thread_queue_Heads *heads, Thread_Control *previous_owner, Thread_queue_Context *queue_context, const Thread_queue_Operations *operations)
Surrenders the thread queue previously owned by the thread to the first enqueued thread.
Definition: threadqenqueue.c:659
Thread queue operations.
Definition: threadq.h:512
uint64_t Priority_Control
The thread priority control.
Definition: priority.h:66
Thread_queue_Queue Queue
The actual thread queue.
Definition: threadq.h:578
Thread_queue_Heads * heads
Lock to protect this thread queue.
Definition: threadq.h:421
Thread queue heads.
Definition: threadq.h:355
void _Thread_Priority_remove(Thread_Control *the_thread, Priority_Node *priority_node, Thread_queue_Context *queue_context)
Removes the specified thread priority node from the corresponding thread priority aggregation...
Definition: threadchangepriority.c:292
RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_default_critical(Thread_Control *the_thread, ISR_lock_Context *lock_context)
Acquires the thread wait default lock inside a critical section (interrupts disabled).
Definition: threadimpl.h:1160
Per CPU Core Structure.
Definition: percpu.h:290
void _Thread_queue_Extract_critical(Thread_queue_Queue *queue, const Thread_queue_Operations *operations, Thread_Control *the_thread, Thread_queue_Context *queue_context)
Extracts the thread from the thread queue and unblocks it.
Definition: threadqenqueue.c:599
Thread_queue_Lock_context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:198
Objects_Control Object
Definition: thread.h:730
RTEMS_INLINE_ROUTINE bool _Objects_Is_local_id(Objects_Id id RTEMS_UNUSED)
Definition: objectimpl.h:623
CORE_mutex_Control Mutex
The plain non-recursive mutex.
Definition: coremutex.h:67
The recursive mutex control.
Definition: coremutex.h:63
struct Scheduler_Node::@3976 Wait
Thread wait support block.
Control block used to manage each mutex.
Definition: coremutex.h:51
Scheduler control.
Definition: scheduler.h:266
Scheduler node for per-thread data.
Definition: schedulernode.h:65
const Scheduler_Control _Scheduler_Table[]
Registered schedulers.
Inlined Routines from the Thread Handler.
RTEMS_INLINE_ROUTINE void _Thread_Wait_release(Thread_Control *the_thread, Thread_queue_Context *queue_context)
Releases the thread wait lock and restores the previous interrupt status.
Definition: threadimpl.h:1413
RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_locked(const CORE_mutex_Control *the_mutex)
Is mutex locked.
Definition: coremuteximpl.h:88
RTEMS_INLINE_ROUTINE Per_CPU_Control * _Thread_Dispatch_disable_critical(const ISR_lock_Context *lock_context)
Disables thread dispatching inside a critical section (interrupts disabled).
Definition: threaddispatch.h:175
The recursive mutex control with priority ceiling protocol support.
Definition: coremutex.h:78
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
ISR_lock_Context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:125
void _Thread_Dispatch_enable(Per_CPU_Control *cpu_self)
Enables thread dispatching.
Definition: threaddispatch.c:353
RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire(Thread_Control *the_thread, Thread_queue_Context *queue_context)
Acquires the thread wait default lock and disables interrupts.
Definition: threadimpl.h:1352
RTEMS_INLINE_ROUTINE void _Thread_Wait_release_default_critical(Thread_Control *the_thread, ISR_lock_Context *lock_context)
Releases the thread wait default lock inside a critical section (interrupts disabled).
Definition: threadimpl.h:1220
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77
Objects_Id id
Definition: objectdata.h:43