summaryrefslogtreecommitdiffstats
path: root/cpukit/score
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-05-17 14:46:02 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-05-26 13:40:24 +0200
commit3cef3198a560d2c9e16afb81f97e05bdc6f13a01 (patch)
tree767704c9062af074884eba3907bcaf0709712aec /cpukit/score
parentrtems: Return RTEMS_CALLED_FROM_ISR (diff)
downloadrtems-3cef3198a560d2c9e16afb81f97e05bdc6f13a01.tar.bz2
score: Simplify calling _Thread_Exit()
Move common code into _Thread_Exit(). This enables a tail call optimization in most cases.
Diffstat (limited to 'cpukit/score')
-rw-r--r--cpukit/score/src/threadrestart.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index c8f7f7b6b1..0ba5ca24ba 100644
--- a/cpukit/score/src/threadrestart.c
+++ b/cpukit/score/src/threadrestart.c
@@ -489,14 +489,19 @@ void _Thread_Close(
);
}
-void _Thread_Exit(
- Thread_Control *executing,
- Thread_Life_state life_states_to_set,
- void *exit_value
+RTEMS_NO_RETURN void _Thread_Exit(
+ void *exit_value,
+ Thread_Life_state life_states_to_set
)
{
+ Per_CPU_Control *cpu_self;
+ Thread_Control *executing;
ISR_lock_Context lock_context;
+ _ISR_lock_ISR_disable( &lock_context );
+ cpu_self = _Thread_Dispatch_disable_critical( &lock_context );
+ executing = _Per_CPU_Get_executing( cpu_self );
+
_Assert(
_Watchdog_Get_state( &executing->Timer.Watchdog ) == WATCHDOG_INACTIVE
);
@@ -505,7 +510,7 @@ void _Thread_Exit(
|| executing->current_state == STATES_SUSPENDED
);
- _Thread_State_acquire( executing, &lock_context );
+ _Thread_State_acquire_critical( executing, &lock_context );
_Thread_Set_exit_value( executing, exit_value );
_Thread_Change_life_locked(
executing,
@@ -514,6 +519,9 @@ void _Thread_Exit(
THREAD_LIFE_PROTECTED | THREAD_LIFE_CHANGE_DEFERRED
);
_Thread_State_release( executing, &lock_context );
+
+ _Thread_Dispatch_direct_no_return( cpu_self );
+ RTEMS_UNREACHABLE();
}
Status_Control _Thread_Restart(