summaryrefslogtreecommitdiff
path: root/cpukit/score/src/threadrestart.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/score/src/threadrestart.c')
-rw-r--r--cpukit/score/src/threadrestart.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index 4e892f75f1..3350bfe464 100644
--- a/cpukit/score/src/threadrestart.c
+++ b/cpukit/score/src/threadrestart.c
@@ -25,6 +25,7 @@
#include <rtems/score/apimutex.h>
#include <rtems/score/assert.h>
#include <rtems/score/chainimpl.h>
+#include <rtems/score/freechainimpl.h>
#include <rtems/score/isrlock.h>
#include <rtems/score/schedulerimpl.h>
#include <rtems/score/stackimpl.h>
@@ -175,7 +176,7 @@ static void _Thread_Free( Thread_Control *the_thread )
#endif
#endif
- _Freechain_Put(
+ _Freechain_Push(
&information->Thread_queue_heads.Free,
the_thread->Wait.spare_heads
);
@@ -184,7 +185,7 @@ static void _Thread_Free( Thread_Control *the_thread )
* Free the rest of the memory associated with this task
* and set the associated pointers to NULL for safety.
*/
- _Stack_Free( the_thread->Start.allocated_stack );
+ ( *the_thread->Start.stack_free )( the_thread->Start.Initial_stack.area );
#if defined(RTEMS_SMP)
_ISR_lock_Destroy( &the_thread->Scheduler.Lock );
@@ -336,6 +337,18 @@ void _Thread_Life_action_handler(
_Thread_State_acquire( executing, lock_context );
+ /*
+ * The executing thread runs with thread dispatching disabled right now.
+ * Other threads may have suspended the executing thread. The thread life
+ * handler may run in parallel with _Thread_Add_life_change_request() which
+ * may have set STATES_LIFE_IS_CHANGING.
+ */
+ _Assert(
+ executing->current_state == STATES_READY
+ || executing->current_state == STATES_SUSPENDED
+ || executing->current_state == STATES_LIFE_IS_CHANGING
+ );
+
_Thread_Change_life_locked(
executing,
THREAD_LIFE_PROTECTED | THREAD_LIFE_RESTARTING,
@@ -348,10 +361,6 @@ void _Thread_Life_action_handler(
_Assert(
_Watchdog_Get_state( &executing->Timer.Watchdog ) == WATCHDOG_INACTIVE
);
- _Assert(
- executing->current_state == STATES_READY
- || executing->current_state == STATES_SUSPENDED
- );
_User_extensions_Destroy_iterators( executing );
_Thread_Load_environment( executing );