summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include/rtems/score
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-13 08:16:30 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-20 07:49:39 +0200
commit54550e048d3a49435912797d2024f80671e93267 (patch)
treebf49901187d98cf6a71975bdef7038d3ae0988c2 /cpukit/score/include/rtems/score
parentscore: Simplify _Thread_Life_action_handler() (diff)
downloadrtems-54550e048d3a49435912797d2024f80671e93267.tar.bz2
posix: Rework pthread_join()
Rework pthread_join() to use _Thread_Join(). Close #2402. Update #2555. Update #2626. Close #2714.
Diffstat (limited to '')
-rw-r--r--cpukit/score/include/rtems/score/statesimpl.h7
-rw-r--r--cpukit/score/include/rtems/score/thread.h15
-rw-r--r--cpukit/score/include/rtems/score/threadimpl.h20
3 files changed, 39 insertions, 3 deletions
diff --git a/cpukit/score/include/rtems/score/statesimpl.h b/cpukit/score/include/rtems/score/statesimpl.h
index a560329a17..54052e2b74 100644
--- a/cpukit/score/include/rtems/score/statesimpl.h
+++ b/cpukit/score/include/rtems/score/statesimpl.h
@@ -385,6 +385,13 @@ RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_period (
return (the_states & STATES_WAITING_FOR_PERIOD);
}
+RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_join_at_exit(
+ States_Control the_states
+)
+{
+ return ( the_states & STATES_WAITING_FOR_JOIN_AT_EXIT ) != 0;
+}
+
/**
* This function returns true if the task's state is set in
* way that allows it to be interrupted by a signal.
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h
index dce3d3bd38..352fb2e434 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -525,7 +525,8 @@ typedef struct {
typedef enum {
THREAD_LIFE_PROTECTED = 0x1,
THREAD_LIFE_RESTARTING = 0x2,
- THREAD_LIFE_TERMINATING = 0x4
+ THREAD_LIFE_TERMINATING = 0x4,
+ THREAD_LIFE_DETACHED = 0x10
} Thread_Life_state;
/**
@@ -547,6 +548,18 @@ typedef struct {
* @brief The count of pending life change requests.
*/
uint32_t pending_life_change_requests;
+
+#if defined(RTEMS_POSIX_API)
+ /**
+ * @brief The thread exit value.
+ *
+ * It is,
+ * - the value passed to pthread_exit(), or
+ * - PTHREAD_CANCELED in case it is cancelled via pthread_cancel(), or
+ * - NULL.
+ */
+ void *exit_value;
+#endif
} Thread_Life_control;
#if defined(RTEMS_SMP)
diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h
index e77352389c..cdd7f9b300 100644
--- a/cpukit/score/include/rtems/score/threadimpl.h
+++ b/cpukit/score/include/rtems/score/threadimpl.h
@@ -217,7 +217,11 @@ Thread_Life_state _Thread_Set_life_protection( Thread_Life_state state );
*/
void _Thread_Kill_zombies( void );
-void _Thread_Exit( Thread_Control *executing );
+void _Thread_Exit(
+ Thread_Control *executing,
+ Thread_Life_state set,
+ void *exit_value
+);
void _Thread_Join(
Thread_Control *the_thread,
@@ -226,7 +230,11 @@ void _Thread_Join(
ISR_lock_Context *lock_context
);
-void _Thread_Cancel( Thread_Control *the_thread, Thread_Control *executing );
+void _Thread_Cancel(
+ Thread_Control *the_thread,
+ Thread_Control *executing,
+ void *exit_value
+);
/**
* @brief Closes the thread.
@@ -950,6 +958,14 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_life_changing(
& ( THREAD_LIFE_RESTARTING | THREAD_LIFE_TERMINATING ) ) != 0;
}
+RTEMS_INLINE_ROUTINE bool _Thread_Is_joinable(
+ const Thread_Control *the_thread
+)
+{
+ _Assert( _Thread_State_is_owner( the_thread ) );
+ return ( the_thread->Life.state & THREAD_LIFE_DETACHED ) == 0;
+}
+
/**
* @brief Returns true if the thread owns resources, and false otherwise.
*