23 #ifndef _RTEMS_SCORE_MRSPIMPL_H 24 #define _RTEMS_SCORE_MRSPIMPL_H 28 #if defined(RTEMS_SMP) 31 #include <rtems/score/status.h> 45 #define MRSP_TQ_OPERATIONS &_Thread_queue_Operations_priority_inherit 83 const MRSP_Control *mrsp
86 return mrsp->Wait_queue.Queue.owner;
100 mrsp->Wait_queue.Queue.owner = owner;
112 const MRSP_Control *mrsp,
116 uint32_t scheduler_index;
119 return mrsp->ceiling_priorities[ scheduler_index ];
135 uint32_t scheduler_index;
138 mrsp->ceiling_priorities[ scheduler_index ] = new_priority;
161 Status_Control status;
172 ceiling_priority = _MRSP_Get_priority( mrsp, scheduler );
180 status = STATUS_SUCCESSFUL;
182 status = STATUS_MUTEX_CEILING_VIOLATED;
230 &mrsp->Ceiling_priority
252 Status_Control status;
255 status = _MRSP_Raise_priority(
258 &mrsp->Ceiling_priority,
262 if ( status != STATUS_SUCCESSFUL ) {
263 _MRSP_Release( mrsp, queue_context );
267 _MRSP_Set_owner( mrsp, executing );
269 _MRSP_Release( mrsp, queue_context );
270 _Thread_Priority_and_sticky_update( executing, 1 );
272 return STATUS_SUCCESSFUL;
294 bool initially_locked
300 if ( initially_locked ) {
301 return STATUS_INVALID_NUMBER;
304 for ( i = 0 ; i < scheduler_count ; ++i ) {
309 if ( scheduler != scheduler_of_index ) {
310 mrsp->ceiling_priorities[ i ] =
313 mrsp->ceiling_priorities[ i ] = ceiling_priority;
318 return STATUS_SUCCESSFUL;
340 Status_Control status;
343 status = _MRSP_Raise_priority(
350 if ( status != STATUS_SUCCESSFUL ) {
351 _MRSP_Release( mrsp, queue_context );
359 status = _Thread_queue_Enqueue_sticky(
360 &mrsp->Wait_queue.Queue,
366 if ( status == STATUS_SUCCESSFUL ) {
367 _MRSP_Replace_priority( mrsp, executing, &ceiling_priority );
371 int sticky_level_change;
373 if ( status != STATUS_DEADLOCK ) {
374 sticky_level_change = -1;
376 sticky_level_change = 0;
380 _MRSP_Remove_priority( executing, &ceiling_priority, &queue_context );
385 _Thread_Priority_and_sticky_update( executing, sticky_level_change );
413 Status_Control status;
416 _MRSP_Acquire_critical( mrsp, queue_context );
418 owner = _MRSP_Get_owner( mrsp );
420 if ( owner ==
NULL ) {
421 status = _MRSP_Claim_ownership( mrsp, executing, queue_context );
422 }
else if ( owner == executing ) {
423 _MRSP_Release( mrsp, queue_context );
424 status = STATUS_UNAVAILABLE;
426 status = _MRSP_Wait_for_ownership( mrsp, executing, queue_context );
428 _MRSP_Release( mrsp, queue_context );
429 status = STATUS_UNAVAILABLE;
453 if ( _MRSP_Get_owner( mrsp ) != executing ) {
455 return STATUS_NOT_OWNER;
458 _MRSP_Acquire_critical( mrsp, queue_context );
460 _MRSP_Set_owner( mrsp,
NULL );
461 _MRSP_Remove_priority( executing, &mrsp->Ceiling_priority, queue_context );
463 heads = mrsp->Wait_queue.Queue.heads;
465 if ( heads ==
NULL ) {
471 _MRSP_Release( mrsp, queue_context );
472 _Thread_Priority_and_sticky_update( executing, -1 );
474 return STATUS_SUCCESSFUL;
477 _Thread_queue_Surrender_sticky(
478 &mrsp->Wait_queue.Queue,
484 return STATUS_SUCCESSFUL;
499 if ( _MRSP_Get_owner( mrsp ) !=
NULL ) {
500 return STATUS_RESOURCE_IN_USE;
503 return STATUS_SUCCESSFUL;
517 _MRSP_Release( mrsp, queue_context );
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:1632
RTEMS_INLINE_ROUTINE Per_CPU_Control * _Thread_queue_Dispatch_disable(Thread_queue_Context *queue_context)
Disables dispatching in a critical section.
Definition: threadqimpl.h:429
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:179
uint64_t Priority_Control
The thread priority control.
Definition: priority.h:70
RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_default(Thread_Control *the_thread, ISR_lock_Context *lock_context)
Acquires the thread wait default lock and disables interrupts.
Definition: threadimpl.h:1673
Thread queue context for the thread queue methods.
Definition: threadq.h:198
The priority node to build up a priority aggregation.
Definition: priority.h:98
Inlined Routines in the Watchdog Handler.
#define _ISR_lock_ISR_enable(_context)
Restores the saved interrupt state of the ISR lock context.
Definition: isrlock.h:419
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 Priority_Control _Scheduler_Map_priority(const Scheduler_Control *scheduler, Priority_Control priority)
Maps a thread priority from the user domain to the scheduler domain.
Definition: schedulerimpl.h:453
Information for the Assert Handler.
Thread queue heads.
Definition: threadq.h:360
RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_index(const Scheduler_Control *scheduler)
Gets the index of the scheduler.
Definition: schedulerimpl.h:834
RTEMS_INLINE_ROUTINE void _Thread_Wait_release_default(Thread_Control *the_thread, ISR_lock_Context *lock_context)
Releases the thread wait default lock and restores the previous interrupt status.
Definition: threadimpl.h:1708
void _Thread_queue_Deadlock_status(Thread_Control *the_thread)
Sets the thread wait return code to STATUS_DEADLOCK.
Definition: threadqenqueue.c:370
RTEMS_INLINE_ROUTINE void _Thread_queue_Destroy(Thread_queue_Control *the_thread_queue)
Destroys the thread queue.
Definition: threadqimpl.h:1378
Per CPU Core Structure.
Definition: percpu.h:347
#define _Scheduler_Count
Count of registered schedulers.
Definition: scheduler.h:325
RTEMS_INLINE_ROUTINE void _Priority_Node_initialize(Priority_Node *node, Priority_Control priority)
Initializes the priority node to the given priority.
Definition: priorityimpl.h:156
Thread_queue_Lock_context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:203
Constants and Structures Associated with the Manipulation of Objects.
void _Thread_Priority_replace(Thread_Control *the_thread, Priority_Node *victim_node, Priority_Node *replacement_node)
Replaces the victim priority node with the replacement priority node in the corresponding thread prio...
Definition: threadchangepriority.c:323
const Scheduler_Control _Scheduler_Table[]
Registered schedulers.
void _Thread_Dispatch_enable(Per_CPU_Control *cpu_self)
Enables thread dispatching.
Definition: threaddispatch.c:362
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:1692
RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire_critical(Thread_queue_Control *the_thread_queue, Thread_queue_Context *queue_context)
Acquires the thread queue control in a critical section.
Definition: threadqimpl.h:681
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_clear_priority_updates(Thread_queue_Context *queue_context)
Clears the priority update count of the thread queue context.
Definition: threadqimpl.h:338
RTEMS_INLINE_ROUTINE const Scheduler_Control * _Thread_Scheduler_get_home(const Thread_Control *the_thread)
Gets the home scheduler of the thread.
Definition: threadimpl.h:1393
Definitions for Multiprocessor Resource Sharing Protocol (MrsP).
Scheduler control.
Definition: scheduler.h:269
Scheduler node for per-thread data.
Definition: schedulernode.h:79
#define _ISR_lock_ISR_disable(_context)
Disables interrupts and saves the previous interrupt state in the ISR lock context.
Definition: isrlock.h:398
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
struct Scheduler_Node::@3980 Wait
Thread wait support block.
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_deadlock_callout(Thread_queue_Context *queue_context, Thread_queue_Deadlock_callout deadlock_callout)
Sets the deadlock callout in the thread queue context.
Definition: threadqimpl.h:324
RTEMS_INLINE_ROUTINE Priority_Control _Priority_Get_priority(const Priority_Aggregation *aggregation)
Gets the priority aggregation's priority.
Definition: priorityimpl.h:270
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:130
RTEMS_INLINE_ROUTINE void _Thread_queue_Release(Thread_queue_Control *the_thread_queue, Thread_queue_Context *queue_context)
Releases the thread queue control and enables interrupts.
Definition: threadqimpl.h:787
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:66
RTEMS_INLINE_ROUTINE Scheduler_Node * _Thread_Scheduler_get_home_node(const Thread_Control *the_thread)
Gets the scheduler's home node.
Definition: threadimpl.h:1412
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77