15 #ifndef _RTEMS_SCORE_MRSPIMPL_H 16 #define _RTEMS_SCORE_MRSPIMPL_H 18 #include <rtems/score/mrsp.h> 20 #if defined(RTEMS_SMP) 22 #include <rtems/score/assert.h> 23 #include <rtems/score/status.h> 38 #define MRSP_TQ_OPERATIONS &_Thread_queue_Operations_priority_inherit 45 _Thread_queue_Acquire_critical( &mrsp->Wait_queue, queue_context );
53 _Thread_queue_Release( &mrsp->Wait_queue, queue_context );
57 const MRSP_Control *mrsp
60 return mrsp->Wait_queue.Queue.owner;
68 mrsp->Wait_queue.Queue.owner = owner;
72 const MRSP_Control *mrsp,
76 uint32_t scheduler_index;
78 scheduler_index = _Scheduler_Get_index( scheduler );
79 return mrsp->ceiling_priorities[ scheduler_index ];
88 uint32_t scheduler_index;
90 scheduler_index = _Scheduler_Get_index( scheduler );
91 mrsp->ceiling_priorities[ scheduler_index ] = new_priority;
101 Status_Control status;
107 _Thread_queue_Context_clear_priority_updates( queue_context );
110 scheduler = _Thread_Scheduler_get_home( thread );
111 scheduler_node = _Thread_Scheduler_get_home_node( thread );
112 ceiling_priority = _MRSP_Get_priority( mrsp, scheduler );
116 <= _Priority_Get_priority( &scheduler_node->
Wait.Priority )
118 _Priority_Node_initialize( priority_node, ceiling_priority );
120 status = STATUS_SUCCESSFUL;
122 status = STATUS_MUTEX_CEILING_VIOLATED;
137 _Thread_queue_Context_clear_priority_updates( queue_context );
155 &mrsp->Ceiling_priority
166 Status_Control status;
169 status = _MRSP_Raise_priority(
172 &mrsp->Ceiling_priority,
176 if ( status != STATUS_SUCCESSFUL ) {
177 _MRSP_Release( mrsp, queue_context );
181 _MRSP_Set_owner( mrsp, executing );
182 cpu_self = _Thread_queue_Dispatch_disable( queue_context );
183 _MRSP_Release( mrsp, queue_context );
184 _Thread_Priority_and_sticky_update( executing, 1 );
186 return STATUS_SUCCESSFUL;
194 bool initially_locked
200 if ( initially_locked ) {
201 return STATUS_INVALID_NUMBER;
205 sizeof( *mrsp->ceiling_priorities ) * scheduler_count
207 if ( mrsp->ceiling_priorities ==
NULL ) {
208 return STATUS_NO_MEMORY;
211 for ( i = 0 ; i < scheduler_count ; ++i ) {
216 if ( scheduler != scheduler_of_index ) {
217 mrsp->ceiling_priorities[ i ] =
220 mrsp->ceiling_priorities[ i ] = ceiling_priority;
225 return STATUS_SUCCESSFUL;
234 Status_Control status;
237 status = _MRSP_Raise_priority(
244 if ( status != STATUS_SUCCESSFUL ) {
245 _MRSP_Release( mrsp, queue_context );
253 status = _Thread_queue_Enqueue_sticky(
254 &mrsp->Wait_queue.Queue,
260 if ( status == STATUS_SUCCESSFUL ) {
261 _MRSP_Replace_priority( mrsp, executing, &ceiling_priority );
265 int sticky_level_change;
267 if ( status != STATUS_DEADLOCK ) {
268 sticky_level_change = -1;
270 sticky_level_change = 0;
274 _MRSP_Remove_priority( executing, &ceiling_priority, &queue_context );
279 _Thread_Priority_and_sticky_update( executing, sticky_level_change );
293 Status_Control status;
296 _MRSP_Acquire_critical( mrsp, queue_context );
298 owner = _MRSP_Get_owner( mrsp );
300 if ( owner ==
NULL ) {
301 status = _MRSP_Claim_ownership( mrsp, executing, queue_context );
302 }
else if ( owner == executing ) {
303 _MRSP_Release( mrsp, queue_context );
304 status = STATUS_UNAVAILABLE;
306 status = _MRSP_Wait_for_ownership( mrsp, executing, queue_context );
308 _MRSP_Release( mrsp, queue_context );
309 status = STATUS_UNAVAILABLE;
323 if ( _MRSP_Get_owner( mrsp ) != executing ) {
325 return STATUS_NOT_OWNER;
328 _MRSP_Acquire_critical( mrsp, queue_context );
330 _MRSP_Set_owner( mrsp,
NULL );
331 _MRSP_Remove_priority( executing, &mrsp->Ceiling_priority, queue_context );
333 heads = mrsp->Wait_queue.Queue.heads;
335 if ( heads ==
NULL ) {
341 _MRSP_Release( mrsp, queue_context );
342 _Thread_Priority_and_sticky_update( executing, -1 );
344 return STATUS_SUCCESSFUL;
347 _Thread_queue_Surrender_sticky(
348 &mrsp->Wait_queue.Queue,
354 return STATUS_SUCCESSFUL;
359 if ( _MRSP_Get_owner( mrsp ) !=
NULL ) {
360 return STATUS_RESOURCE_IN_USE;
363 return STATUS_SUCCESSFUL;
371 _MRSP_Release( mrsp, queue_context );
372 _Thread_queue_Destroy( &mrsp->Wait_queue );
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
Thread queue context for the thread queue methods.
Definition: threadq.h:193
The priority node to build up a priority aggregation.
Definition: priority.h:94
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
Inlined Routines in the Watchdog Handler.
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:65
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
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:448
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:1236
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:280
uint64_t Priority_Control
The thread priority control.
Definition: priority.h:66
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
#define _ISR_lock_ISR_disable(_context)
Disables interrupts and saves the previous interrupt state in the ISR lock context.
Definition: isrlock.h:383
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
#define _ISR_lock_ISR_enable(_context)
Restores the saved interrupt state of the ISR lock context.
Definition: isrlock.h:404
Per CPU Core Structure.
Definition: percpu.h:290
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:1201
Information Related to the RAM Workspace.
Thread_queue_Lock_context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:198
struct Scheduler_Node::@3976 Wait
Thread wait support block.
void _Workspace_Free(void *block)
Free memory to the workspace.
Definition: wkspace.c:259
Scheduler control.
Definition: scheduler.h:266
Scheduler node for per-thread data.
Definition: schedulernode.h:65
const Scheduler_Control _Scheduler_Table[]
Registered schedulers.
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
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_queue_Deadlock_status(Thread_Control *the_thread)
Sets the thread wait return code to STATUS_DEADLOCK.
Definition: threadqenqueue.c:369
void _Thread_Dispatch_enable(Per_CPU_Control *cpu_self)
Enables thread dispatching.
Definition: threaddispatch.c:353
void * _Workspace_Allocate(size_t size)
Allocate memory from workspace.
Definition: wkspace.c:232
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
#define _Scheduler_Count
Count of registered schedulers.
Definition: scheduler.h:314