summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/rtems')
-rw-r--r--cpukit/rtems/include/rtems/rtems/tasksimpl.h3
-rw-r--r--cpukit/rtems/src/taskdelete.c37
-rw-r--r--cpukit/rtems/src/tasks.c29
-rw-r--r--cpukit/rtems/src/taskvariable_invoke_dtor.c2
4 files changed, 30 insertions, 41 deletions
diff --git a/cpukit/rtems/include/rtems/rtems/tasksimpl.h b/cpukit/rtems/include/rtems/rtems/tasksimpl.h
index fbee00e316..2a99812e26 100644
--- a/cpukit/rtems/include/rtems/rtems/tasksimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/tasksimpl.h
@@ -19,6 +19,7 @@
#include <rtems/rtems/tasks.h>
#include <rtems/score/objectimpl.h>
+#include <rtems/score/threadimpl.h>
#ifdef __cplusplus
extern "C" {
@@ -84,6 +85,8 @@ void _RTEMS_Tasks_Invoke_task_variable_dtor(
*/
RTEMS_INLINE_ROUTINE Thread_Control *_RTEMS_tasks_Allocate( void )
{
+ _Thread_Kill_zombies();
+
return (Thread_Control *) _Objects_Allocate( &_RTEMS_tasks_Information );
}
diff --git a/cpukit/rtems/src/taskdelete.c b/cpukit/rtems/src/taskdelete.c
index b92f5f2a7f..dc9a2a1961 100644
--- a/cpukit/rtems/src/taskdelete.c
+++ b/cpukit/rtems/src/taskdelete.c
@@ -27,32 +27,15 @@ rtems_status_code rtems_task_delete(
rtems_id id
)
{
- Thread_Control *the_thread;
- Objects_Locations location;
- Objects_Information *the_information;
-
-#if defined( RTEMS_SMP )
- if ( rtems_configuration_is_smp_enabled() ) {
- return RTEMS_NOT_IMPLEMENTED;
- }
-#endif
-
- _RTEMS_Lock_allocator();
+ Thread_Control *the_thread;
+ Objects_Locations location;
+ bool previous_life_protection;
+ previous_life_protection = _Thread_Set_life_protection( true );
the_thread = _Thread_Get( id, &location );
switch ( location ) {
case OBJECTS_LOCAL:
- the_information = _Objects_Get_information_id( the_thread->Object.id );
-
- #if defined(RTEMS_DEBUG)
- if ( !the_information ) {
- _Objects_Put( &the_thread->Object );
- return RTEMS_INVALID_ID;
- /* This should never happen if _Thread_Get() works right */
- }
- #endif
-
#if defined(RTEMS_MULTIPROCESSING)
if ( the_thread->is_global ) {
_Objects_MP_Close( &_RTEMS_tasks_Information, the_thread->Object.id );
@@ -64,19 +47,16 @@ rtems_status_code rtems_task_delete(
}
#endif
- _Thread_Close( the_information, the_thread );
+ _Thread_Close( the_thread, _Thread_Executing );
- _RTEMS_tasks_Free( the_thread );
-
- /* FIXME: Lock order reversal */
- _RTEMS_Unlock_allocator();
_Objects_Put( &the_thread->Object );
+ _Thread_Set_life_protection( previous_life_protection );
return RTEMS_SUCCESSFUL;
#if defined(RTEMS_MULTIPROCESSING)
case OBJECTS_REMOTE:
- _RTEMS_Unlock_allocator();
_Thread_Dispatch();
+ _Thread_Set_life_protection( previous_life_protection );
return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
#endif
@@ -84,6 +64,7 @@ rtems_status_code rtems_task_delete(
break;
}
- _RTEMS_Unlock_allocator();
+ _Thread_Set_life_protection( previous_life_protection );
+
return RTEMS_INVALID_ID;
}
diff --git a/cpukit/rtems/src/tasks.c b/cpukit/rtems/src/tasks.c
index c859d248b5..594695080a 100644
--- a/cpukit/rtems/src/tasks.c
+++ b/cpukit/rtems/src/tasks.c
@@ -113,31 +113,35 @@ static void _RTEMS_tasks_Delete_extension(
Thread_Control *deleted
)
{
+ /*
+ * Free API specific memory
+ */
+
+ (void) _Workspace_Free( deleted->API_Extensions[ THREAD_API_RTEMS ] );
+}
+
+static void _RTEMS_tasks_Terminate_extension(
+ Thread_Control *executing
+)
+{
rtems_task_variable_t *tvp, *next;
/*
* Free per task variable memory
*/
- tvp = deleted->task_variables;
- deleted->task_variables = NULL;
+ tvp = executing->task_variables;
+ executing->task_variables = NULL;
while (tvp) {
next = (rtems_task_variable_t *)tvp->next;
- _RTEMS_Tasks_Invoke_task_variable_dtor( deleted, tvp );
+ _RTEMS_Tasks_Invoke_task_variable_dtor( executing, tvp );
tvp = next;
}
/*
* Run all the key destructors
*/
- _POSIX_Keys_Run_destructors( deleted );
-
- /*
- * Free API specific memory
- */
-
- (void) _Workspace_Free( deleted->API_Extensions[ THREAD_API_RTEMS ] );
- deleted->API_Extensions[ THREAD_API_RTEMS ] = NULL;
+ _POSIX_Keys_Run_destructors( executing );
}
/*
@@ -189,7 +193,8 @@ User_extensions_Control _RTEMS_tasks_User_extensions = {
_RTEMS_tasks_Switch_extension, /* switch */
NULL, /* begin */
NULL, /* exitted */
- NULL /* fatal */
+ NULL, /* fatal */
+ _RTEMS_tasks_Terminate_extension /* terminate */
}
};
diff --git a/cpukit/rtems/src/taskvariable_invoke_dtor.c b/cpukit/rtems/src/taskvariable_invoke_dtor.c
index a23e5e56fa..51b9453d82 100644
--- a/cpukit/rtems/src/taskvariable_invoke_dtor.c
+++ b/cpukit/rtems/src/taskvariable_invoke_dtor.c
@@ -31,7 +31,7 @@ void _RTEMS_Tasks_Invoke_task_variable_dtor(
void *value;
dtor = tvp->dtor;
- if (_Thread_Is_executing(the_thread)) {
+ if (_Thread_Get_executing() == the_thread) {
value = *tvp->ptr;
*tvp->ptr = tvp->gval;
} else {