diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-03-25 10:54:49 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-03-31 08:29:43 +0200 |
commit | 1b1be254e7a3e3d6fe6d55d62010a81a7ef35411 (patch) | |
tree | c8bacf15b0f092728fd69debcb2387b65db33ed0 /cpukit/rtems/src/tasks.c | |
parent | score: Replace _Thread_Reset() (diff) | |
download | rtems-1b1be254e7a3e3d6fe6d55d62010a81a7ef35411.tar.bz2 |
score: Thread life cycle re-implementation
The thread deletion is now supported on SMP.
This change fixes the following PRs:
PR1814: SMP race condition between stack free and dispatch
PR2035: psxcancel reveals NULL pointer access in _Thread_queue_Extract()
The POSIX cleanup handler are now called in the right context (should be
called in the context of the terminating thread).
http://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_09.html
Add a user extension the reflects a thread termination event. This is
used to reclaim the Newlib reentrancy structure (may use file
operations), the POSIX cleanup handlers and the POSIX key destructors.
Diffstat (limited to '')
-rw-r--r-- | cpukit/rtems/src/tasks.c | 29 |
1 files changed, 17 insertions, 12 deletions
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 */ } }; |