summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include/rtems/score/threadimpl.h
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-03-25 10:54:49 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-03-31 08:29:43 +0200
commit1b1be254e7a3e3d6fe6d55d62010a81a7ef35411 (patch)
treec8bacf15b0f092728fd69debcb2387b65db33ed0 /cpukit/score/include/rtems/score/threadimpl.h
parentscore: Replace _Thread_Reset() (diff)
downloadrtems-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 'cpukit/score/include/rtems/score/threadimpl.h')
-rw-r--r--cpukit/score/include/rtems/score/threadimpl.h56
1 files changed, 48 insertions, 8 deletions
diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h
index 2e31753817..d0c7933aa3 100644
--- a/cpukit/score/include/rtems/score/threadimpl.h
+++ b/cpukit/score/include/rtems/score/threadimpl.h
@@ -11,6 +11,8 @@
* COPYRIGHT (c) 1989-2008.
* On-Line Applications Research Corporation (OAR).
*
+ * Copyright (c) 2014 embedded brains GmbH.
+ *
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
@@ -194,6 +196,8 @@ bool _Thread_Restart(
Thread_Entry_numeric_type numeric_argument
);
+bool _Thread_Set_life_protection( bool protect );
+
void _Thread_Life_action_handler(
Thread_Control *executing,
Thread_Action *action,
@@ -202,16 +206,24 @@ void _Thread_Life_action_handler(
);
/**
- * @brief Frees all memory associated with the specified thread.
+ * @brief Kills all zombie threads in the system.
*
- * This routine frees all memory associated with the specified
- * thread and removes it from the local object table so no further
- * operations on this thread are allowed.
+ * Threads change into the zombie state as the last step in the thread
+ * termination sequence right before a context switch to the heir thread is
+ * initiated. Since the thread stack is still in use during this phase we have
+ * to postpone the thread stack reclamation until this point. On SMP
+ * configurations we may have to busy wait for context switch completion here.
*/
-void _Thread_Close(
- Objects_Information *information,
- Thread_Control *the_thread
-);
+void _Thread_Kill_zombies( void );
+
+/**
+ * @brief Closes the thread.
+ *
+ * Closes the thread object and starts the thread termination sequence. In
+ * case the executing thread is not terminated, then this function waits until
+ * the terminating thread reached the zombie state.
+ */
+void _Thread_Close( Thread_Control *the_thread, Thread_Control *executing );
/**
* @brief Removes any set states for @a the_thread.
@@ -710,6 +722,34 @@ RTEMS_INLINE_ROUTINE void _Thread_Add_post_switch_action(
_Thread_Action_release_and_ISR_enable( cpu, level );
}
+RTEMS_INLINE_ROUTINE bool _Thread_Is_life_restarting(
+ Thread_Life_state life_state
+)
+{
+ return ( life_state & THREAD_LIFE_RESTARTING ) != 0;
+}
+
+RTEMS_INLINE_ROUTINE bool _Thread_Is_life_terminating(
+ Thread_Life_state life_state
+)
+{
+ return ( life_state & THREAD_LIFE_TERMINATING ) != 0;
+}
+
+RTEMS_INLINE_ROUTINE bool _Thread_Is_life_protected(
+ Thread_Life_state life_state
+)
+{
+ return ( life_state & THREAD_LIFE_PROTECTED ) != 0;
+}
+
+RTEMS_INLINE_ROUTINE bool _Thread_Is_life_changing(
+ Thread_Life_state life_state
+)
+{
+ return ( life_state & THREAD_LIFE_RESTARTING_TERMINTING ) != 0;
+}
+
#if !defined(__DYNAMIC_REENT__)
/**
* This routine returns the C library re-enterant pointer.