mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-26 12:54:05 +08:00
score: Initialize thread queue context early
Initialize thread queue context early preferably outside the critical section. Remove implicit _Thread_queue_Context_initialize() from _Thread_Wait_acquire().
This commit is contained in:
@@ -22,6 +22,7 @@ rtems_monitor_task_wait_info(
|
||||
{
|
||||
Thread_queue_Context queue_context;
|
||||
|
||||
_Thread_queue_Context_initialize( &queue_context );
|
||||
_Thread_Wait_acquire( rtems_thread, &queue_context );
|
||||
|
||||
canonical_task->state = rtems_thread->current_state;
|
||||
|
||||
@@ -67,6 +67,8 @@ int pthread_mutex_setprioceiling(
|
||||
Thread_queue_Context queue_context;
|
||||
Per_CPU_Control *cpu_self;
|
||||
|
||||
_Thread_queue_Context_initialize( &queue_context );
|
||||
_Thread_queue_Context_clear_priority_updates( &queue_context );
|
||||
_CORE_ceiling_mutex_Set_priority(
|
||||
&the_mutex->Mutex,
|
||||
new_priority,
|
||||
|
||||
@@ -91,8 +91,9 @@ void _POSIX_Threads_Sporadic_timer( Watchdog_Control *watchdog )
|
||||
api = RTEMS_CONTAINER_OF( watchdog, POSIX_API_Control, Sporadic.Timer );
|
||||
the_thread = api->thread;
|
||||
|
||||
_Thread_Wait_acquire( the_thread, &queue_context );
|
||||
_Thread_queue_Context_initialize( &queue_context );
|
||||
_Thread_queue_Context_clear_priority_updates( &queue_context );
|
||||
_Thread_Wait_acquire( the_thread, &queue_context );
|
||||
|
||||
if ( _Priority_Node_is_active( &api->Sporadic.Low_priority ) ) {
|
||||
_Thread_Priority_add(
|
||||
@@ -122,8 +123,9 @@ void _POSIX_Threads_Sporadic_budget_callout( Thread_Control *the_thread )
|
||||
|
||||
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
||||
|
||||
_Thread_Wait_acquire( the_thread, &queue_context );
|
||||
_Thread_queue_Context_initialize( &queue_context );
|
||||
_Thread_queue_Context_clear_priority_updates( &queue_context );
|
||||
_Thread_Wait_acquire( the_thread, &queue_context );
|
||||
|
||||
/*
|
||||
* This will prevent the thread from consuming its entire "budget"
|
||||
|
||||
@@ -45,6 +45,7 @@ int pthread_getschedparam(
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
_Thread_queue_Context_initialize( &queue_context );
|
||||
the_thread = _Thread_Get( thread, &queue_context.Lock_context.Lock_context );
|
||||
|
||||
if ( the_thread == NULL ) {
|
||||
@@ -53,7 +54,6 @@ int pthread_getschedparam(
|
||||
|
||||
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
||||
|
||||
_Thread_queue_Context_initialize( &queue_context );
|
||||
_Thread_Wait_acquire_critical( the_thread, &queue_context );
|
||||
|
||||
*policy = api->Attributes.schedpolicy;
|
||||
|
||||
@@ -138,13 +138,14 @@ int pthread_setschedparam(
|
||||
return error;
|
||||
}
|
||||
|
||||
_Thread_queue_Context_initialize( &queue_context );
|
||||
_Thread_queue_Context_clear_priority_updates( &queue_context );
|
||||
the_thread = _Thread_Get( thread, &queue_context.Lock_context.Lock_context );
|
||||
|
||||
if ( the_thread == NULL ) {
|
||||
return ESRCH;
|
||||
}
|
||||
|
||||
_Thread_queue_Context_clear_priority_updates( &queue_context );
|
||||
_Thread_Wait_acquire_critical( the_thread, &queue_context );
|
||||
error = _POSIX_Set_sched_param(
|
||||
the_thread,
|
||||
|
||||
@@ -27,13 +27,14 @@ int pthread_setschedprio( pthread_t thread, int prio )
|
||||
Priority_Control new_priority;
|
||||
bool valid;
|
||||
|
||||
_Thread_queue_Context_initialize( &queue_context );
|
||||
_Thread_queue_Context_clear_priority_updates( &queue_context );
|
||||
the_thread = _Thread_Get( thread, &queue_context.Lock_context.Lock_context );
|
||||
|
||||
if ( the_thread == NULL ) {
|
||||
return ESRCH;
|
||||
}
|
||||
|
||||
_Thread_queue_Context_clear_priority_updates( &queue_context );
|
||||
_Thread_Wait_acquire_critical( the_thread, &queue_context );
|
||||
|
||||
scheduler = _Thread_Scheduler_get_home( the_thread );
|
||||
|
||||
@@ -41,6 +41,7 @@ static bool _Scheduler_Check_processor_removal(
|
||||
|
||||
iter_context = arg;
|
||||
|
||||
_Thread_queue_Context_initialize( &queue_context );
|
||||
_Thread_Wait_acquire( the_thread, &queue_context );
|
||||
_Thread_State_acquire_critical( the_thread, &state_context );
|
||||
|
||||
|
||||
@@ -168,6 +168,7 @@ rtems_status_code rtems_semaphore_create(
|
||||
Thread_queue_Context queue_context;
|
||||
|
||||
_Thread_queue_Context_initialize( &queue_context );
|
||||
_Thread_queue_Context_clear_priority_updates( &queue_context );
|
||||
_ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context );
|
||||
_CORE_mutex_Acquire_critical(
|
||||
&the_semaphore->Core_control.Mutex.Recursive.Mutex,
|
||||
|
||||
@@ -44,7 +44,6 @@ static rtems_status_code _RTEMS_tasks_Set_priority(
|
||||
return RTEMS_INVALID_PRIORITY;
|
||||
}
|
||||
|
||||
_Thread_queue_Context_clear_priority_updates( queue_context );
|
||||
_Thread_Priority_change(
|
||||
the_thread,
|
||||
&the_thread->Real_priority,
|
||||
@@ -78,6 +77,7 @@ rtems_status_code rtems_task_set_priority(
|
||||
}
|
||||
|
||||
_Thread_queue_Context_initialize( &queue_context );
|
||||
_Thread_queue_Context_clear_priority_updates( &queue_context );
|
||||
the_thread = _Thread_Get( id, &queue_context.Lock_context.Lock_context );
|
||||
|
||||
if ( the_thread == NULL ) {
|
||||
|
||||
@@ -253,7 +253,6 @@ RTEMS_INLINE_ROUTINE void _CORE_ceiling_mutex_Set_priority(
|
||||
|
||||
if ( owner != NULL ) {
|
||||
_Thread_Wait_acquire( owner, queue_context );
|
||||
_Thread_queue_Context_clear_priority_updates( queue_context );
|
||||
_Thread_Priority_change(
|
||||
owner,
|
||||
&the_mutex->Priority_ceiling,
|
||||
@@ -284,7 +283,6 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Set_owner(
|
||||
Scheduler_Node *scheduler_node;
|
||||
Per_CPU_Control *cpu_self;
|
||||
|
||||
_Thread_queue_Context_clear_priority_updates( queue_context );
|
||||
_Thread_Wait_acquire_default_critical( owner, &lock_context );
|
||||
|
||||
scheduler_node = _Thread_Scheduler_get_home_node( owner );
|
||||
@@ -341,6 +339,7 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Seize(
|
||||
}
|
||||
#endif
|
||||
|
||||
_Thread_queue_Context_clear_priority_updates( queue_context );
|
||||
return _CORE_ceiling_mutex_Set_owner(
|
||||
the_mutex,
|
||||
executing,
|
||||
|
||||
@@ -132,7 +132,7 @@ RTEMS_INLINE_ROUTINE void _MRSP_Remove_priority(
|
||||
Thread_queue_Context *queue_context
|
||||
)
|
||||
{
|
||||
ISR_lock_Context lock_context;
|
||||
ISR_lock_Context lock_context;
|
||||
|
||||
_Thread_queue_Context_clear_priority_updates( queue_context );
|
||||
_Thread_Wait_acquire_default_critical( thread, &lock_context );
|
||||
|
||||
@@ -1333,8 +1333,6 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_release_queue_critical(
|
||||
* @param[in] the_thread The thread.
|
||||
* @param[in] queue_context The thread queue context for the corresponding
|
||||
* _Thread_Wait_release_critical().
|
||||
*
|
||||
* @see _Thread_queue_Context_initialize().
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_critical(
|
||||
Thread_Control *the_thread,
|
||||
@@ -1397,7 +1395,6 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire(
|
||||
Thread_queue_Context *queue_context
|
||||
)
|
||||
{
|
||||
_Thread_queue_Context_initialize( queue_context );
|
||||
_ISR_lock_ISR_disable( &queue_context->Lock_context.Lock_context );
|
||||
_Thread_Wait_acquire_critical( the_thread, queue_context );
|
||||
}
|
||||
|
||||
@@ -57,8 +57,9 @@ static void _Thread_Raise_real_priority(
|
||||
{
|
||||
Thread_queue_Context queue_context;
|
||||
|
||||
_Thread_Wait_acquire( the_thread, &queue_context );
|
||||
_Thread_queue_Context_initialize( &queue_context );
|
||||
_Thread_queue_Context_clear_priority_updates( &queue_context );
|
||||
_Thread_Wait_acquire( the_thread, &queue_context );
|
||||
|
||||
if ( priority < the_thread->Real_priority.priority ) {
|
||||
_Thread_Priority_change(
|
||||
@@ -637,6 +638,8 @@ void _Thread_Restart_self(
|
||||
|| executing->current_state == STATES_SUSPENDED
|
||||
);
|
||||
|
||||
_Thread_queue_Context_initialize( &queue_context );
|
||||
_Thread_queue_Context_clear_priority_updates( &queue_context );
|
||||
_Thread_State_acquire_critical( executing, lock_context );
|
||||
|
||||
executing->Start.Entry = *entry;
|
||||
@@ -650,7 +653,6 @@ void _Thread_Restart_self(
|
||||
cpu_self = _Thread_Dispatch_disable_critical( lock_context );
|
||||
_Thread_State_release( executing, lock_context );
|
||||
|
||||
_Thread_queue_Context_clear_priority_updates( &queue_context );
|
||||
_Thread_Wait_acquire_default( executing, lock_context );
|
||||
_Thread_Priority_change(
|
||||
executing,
|
||||
|
||||
@@ -31,8 +31,9 @@ void _Thread_Timeout( Watchdog_Control *watchdog )
|
||||
|
||||
the_thread = RTEMS_CONTAINER_OF( watchdog, Thread_Control, Timer.Watchdog );
|
||||
|
||||
_Thread_Wait_acquire( the_thread, &queue_context );
|
||||
_Thread_queue_Context_initialize( &queue_context );
|
||||
_Thread_queue_Context_clear_priority_updates( &queue_context );
|
||||
_Thread_Wait_acquire( the_thread, &queue_context );
|
||||
|
||||
wait_flags = _Thread_Wait_flags_get( the_thread );
|
||||
|
||||
|
||||
@@ -52,8 +52,9 @@ static void apply_priority(
|
||||
Thread_queue_Context *queue_context
|
||||
)
|
||||
{
|
||||
_Thread_Wait_acquire(thread, queue_context);
|
||||
_Thread_queue_Context_initialize(queue_context);
|
||||
_Thread_queue_Context_clear_priority_updates(queue_context);
|
||||
_Thread_Wait_acquire(thread, queue_context);
|
||||
_Thread_Priority_change(
|
||||
thread,
|
||||
&thread->Real_priority,
|
||||
|
||||
@@ -71,6 +71,7 @@ static rtems_id get_wait_id(test_context *ctx)
|
||||
Thread_queue_Context queue_context;
|
||||
rtems_id id;
|
||||
|
||||
_Thread_queue_Context_initialize(&queue_context);
|
||||
_Thread_Wait_acquire(ctx->master, &queue_context);
|
||||
id = _Thread_Wait_get_id(ctx->master);
|
||||
_Thread_Wait_release(ctx->master, &queue_context);
|
||||
|
||||
Reference in New Issue
Block a user