forked from Imagelibrary/rtems
score: Untangle thread actions
Remove the thread action handler parameter from _Thread_Action_initialize() and instead set it later in _Thread_Add_post_switch_action(). This avoids a dependency on the thread action handler via the thread initialization.
This commit is contained in:
@@ -40,7 +40,11 @@ static bool _POSIX_signals_Unblock_thread_done(
|
||||
bool status
|
||||
)
|
||||
{
|
||||
_Thread_Add_post_switch_action( the_thread, &api->Signal_action );
|
||||
_Thread_Add_post_switch_action(
|
||||
the_thread,
|
||||
&api->Signal_action,
|
||||
_POSIX_signals_Action_handler
|
||||
);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -229,11 +229,7 @@ static bool _POSIX_Threads_Create_extension(
|
||||
api->signals_blocked = SIGNAL_ALL_MASK;
|
||||
}
|
||||
|
||||
_Thread_Action_initialize(
|
||||
&api->Signal_action,
|
||||
_POSIX_signals_Action_handler
|
||||
);
|
||||
|
||||
_Thread_Action_initialize( &api->Signal_action );
|
||||
_Thread_queue_Initialize( &api->Join_List, THREAD_QUEUE_DISCIPLINE_FIFO );
|
||||
|
||||
_Watchdog_Preinitialize( &api->Sporadic_timer );
|
||||
|
||||
@@ -49,7 +49,8 @@ rtems_status_code rtems_signal_send(
|
||||
_ASR_Post_signals( asr, signal_set, &asr->signals_posted );
|
||||
_Thread_Add_post_switch_action(
|
||||
the_thread,
|
||||
&api->Signal_action
|
||||
&api->Signal_action,
|
||||
_Signal_Action_handler
|
||||
);
|
||||
} else {
|
||||
_ASR_Post_signals( asr, signal_set, &asr->signals_pending );
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <rtems/rtems/tasks.h>
|
||||
#include <rtems/rtems/asrimpl.h>
|
||||
#include <rtems/rtems/modesimpl.h>
|
||||
#include <rtems/rtems/signalimpl.h>
|
||||
#include <rtems/score/schedulerimpl.h>
|
||||
#include <rtems/score/threadimpl.h>
|
||||
#include <rtems/config.h>
|
||||
@@ -103,7 +104,8 @@ rtems_status_code rtems_task_mode(
|
||||
needs_asr_dispatching = true;
|
||||
_Thread_Add_post_switch_action(
|
||||
executing,
|
||||
&api->Signal_action
|
||||
&api->Signal_action,
|
||||
_Signal_Action_handler
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ static bool _RTEMS_tasks_Create_extension(
|
||||
api = created->API_Extensions[ THREAD_API_RTEMS ];
|
||||
|
||||
_ASR_Create( &api->Signal );
|
||||
_Thread_Action_initialize( &api->Signal_action, _Signal_Action_handler );
|
||||
_Thread_Action_initialize( &api->Signal_action );
|
||||
#if !defined(RTEMS_SMP)
|
||||
created->task_variables = NULL;
|
||||
#endif
|
||||
|
||||
@@ -847,11 +847,9 @@ RTEMS_INLINE_ROUTINE void _Thread_Action_control_initialize(
|
||||
}
|
||||
|
||||
RTEMS_INLINE_ROUTINE void _Thread_Action_initialize(
|
||||
Thread_Action *action,
|
||||
Thread_Action_handler handler
|
||||
Thread_Action *action
|
||||
)
|
||||
{
|
||||
action->handler = handler;
|
||||
_Chain_Set_off_chain( &action->Node );
|
||||
}
|
||||
|
||||
@@ -890,8 +888,9 @@ RTEMS_INLINE_ROUTINE void _Thread_Action_release_and_ISR_enable(
|
||||
}
|
||||
|
||||
RTEMS_INLINE_ROUTINE void _Thread_Add_post_switch_action(
|
||||
Thread_Control *thread,
|
||||
Thread_Action *action
|
||||
Thread_Control *thread,
|
||||
Thread_Action *action,
|
||||
Thread_Action_handler handler
|
||||
)
|
||||
{
|
||||
Per_CPU_Control *cpu_of_thread;
|
||||
@@ -899,6 +898,8 @@ RTEMS_INLINE_ROUTINE void _Thread_Add_post_switch_action(
|
||||
|
||||
cpu_of_thread = _Thread_Action_ISR_disable_and_acquire( thread, &level );
|
||||
|
||||
action->handler = handler;
|
||||
|
||||
#if defined(RTEMS_SMP)
|
||||
if ( _Per_CPU_Get() == cpu_of_thread ) {
|
||||
cpu_of_thread->dispatch_necessary = true;
|
||||
|
||||
@@ -243,10 +243,7 @@ bool _Thread_Initialize(
|
||||
|
||||
_Thread_Action_control_initialize( &the_thread->Post_switch_actions );
|
||||
|
||||
_Thread_Action_initialize(
|
||||
&the_thread->Life.Action,
|
||||
_Thread_Life_action_handler
|
||||
);
|
||||
_Thread_Action_initialize( &the_thread->Life.Action );
|
||||
the_thread->Life.state = THREAD_LIFE_NORMAL;
|
||||
the_thread->Life.terminator = NULL;
|
||||
|
||||
|
||||
@@ -176,6 +176,17 @@ void _Thread_Kill_zombies( void )
|
||||
_ISR_lock_Release_and_ISR_enable( &zombies->Lock, &lock_context );
|
||||
}
|
||||
|
||||
static void _Thread_Add_life_change_action(
|
||||
Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
_Thread_Add_post_switch_action(
|
||||
the_thread,
|
||||
&the_thread->Life.Action,
|
||||
_Thread_Life_action_handler
|
||||
);
|
||||
}
|
||||
|
||||
static void _Thread_Start_life_change_for_executing(
|
||||
Thread_Control *executing
|
||||
)
|
||||
@@ -186,7 +197,7 @@ static void _Thread_Start_life_change_for_executing(
|
||||
|| executing->current_state == STATES_SUSPENDED
|
||||
);
|
||||
|
||||
_Thread_Add_post_switch_action( executing, &executing->Life.Action );
|
||||
_Thread_Add_life_change_action( executing );
|
||||
}
|
||||
|
||||
void _Thread_Life_action_handler(
|
||||
@@ -271,7 +282,7 @@ static void _Thread_Start_life_change(
|
||||
_Thread_Raise_real_priority_filter,
|
||||
false
|
||||
);
|
||||
_Thread_Add_post_switch_action( the_thread, &the_thread->Life.Action );
|
||||
_Thread_Add_life_change_action( the_thread );
|
||||
_Thread_Ready( the_thread );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user