[rtems commit] score: Fix POSIX thread join

Sebastian Huber sebh at rtems.org
Thu Apr 23 19:42:53 UTC 2015


Module:    rtems
Branch:    master
Commit:    f32935335a7f9b53c14133724753045ead988ca4
Changeset: http://git.rtems.org/rtems/commit/?id=f32935335a7f9b53c14133724753045ead988ca4

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Apr 23 15:25:13 2015 +0200

score: Fix POSIX thread join

A thread join is twofold.  There is one thread that exists and an
arbitrary number of threads that wait for the thread exit (one-to-many
relation).  The exiting thread may want to wait for a thread that wants
to join its exit (STATES_WAITING_FOR_JOIN_AT_EXIT in
_POSIX_Thread_Exit()).  On the other side we need a thread queue for all
the threads that wait for the exit of one particular thread
(STATES_WAITING_FOR_JOIN in pthread_join()).

Update #2035.

---

 cpukit/libmisc/monitor/mon-prmisc.c           | 1 +
 cpukit/posix/src/pthreadjoin.c                | 2 +-
 cpukit/score/include/rtems/score/statesimpl.h | 4 +++-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/cpukit/libmisc/monitor/mon-prmisc.c b/cpukit/libmisc/monitor/mon-prmisc.c
index ff54d79..9140f92 100644
--- a/cpukit/libmisc/monitor/mon-prmisc.c
+++ b/cpukit/libmisc/monitor/mon-prmisc.c
@@ -127,6 +127,7 @@ static const rtems_assoc_t rtems_monitor_state_assoc[] = {
     { "Wmutex", STATES_WAITING_FOR_MUTEX, 0 },
     { "Wcvar",  STATES_WAITING_FOR_CONDITION_VARIABLE, 0 },
     { "Wjatx",  STATES_WAITING_FOR_JOIN_AT_EXIT, 0 },
+    { "Wjoin",  STATES_WAITING_FOR_JOIN, 0 },
     { "Wrpc",   STATES_WAITING_FOR_RPC_REPLY, 0 },
     { "WRATE",  STATES_WAITING_FOR_PERIOD, 0 },
     { "Wsig",   STATES_WAITING_FOR_SIGNAL, 0 },
diff --git a/cpukit/posix/src/pthreadjoin.c b/cpukit/posix/src/pthreadjoin.c
index 99cc4d3..e2b1664 100644
--- a/cpukit/posix/src/pthreadjoin.c
+++ b/cpukit/posix/src/pthreadjoin.c
@@ -71,7 +71,7 @@ on_EINTR:
         _Thread_queue_Enqueue(
           &api->Join_List,
           executing,
-          STATES_WAITING_FOR_JOIN_AT_EXIT | STATES_INTERRUPTIBLE_BY_SIGNAL,
+          STATES_WAITING_FOR_JOIN | STATES_INTERRUPTIBLE_BY_SIGNAL,
           WATCHDOG_NO_TIMEOUT
         );
       }
diff --git a/cpukit/score/include/rtems/score/statesimpl.h b/cpukit/score/include/rtems/score/statesimpl.h
index 074b352..9f94675 100644
--- a/cpukit/score/include/rtems/score/statesimpl.h
+++ b/cpukit/score/include/rtems/score/statesimpl.h
@@ -84,6 +84,8 @@ extern "C" {
 #define STATES_MIGRATING                       0x400000
 /** This macro corresponds to a task restarting. */
 #define STATES_RESTARTING                      0x800000
+/** This macro corresponds to a task waiting for a join. */
+#define STATES_WAITING_FOR_JOIN                0x1000000
 
 /** This macro corresponds to a task which is in an interruptible
  *  blocking state.
@@ -97,7 +99,7 @@ extern "C" {
                                  STATES_WAITING_FOR_SEMAPHORE          | \
                                  STATES_WAITING_FOR_MUTEX              | \
                                  STATES_WAITING_FOR_CONDITION_VARIABLE | \
-                                 STATES_WAITING_FOR_JOIN_AT_EXIT       | \
+                                 STATES_WAITING_FOR_JOIN               | \
                                  STATES_WAITING_FOR_SIGNAL             | \
                                  STATES_WAITING_FOR_BARRIER            | \
                                  STATES_WAITING_FOR_BSD_WAKEUP         | \




More information about the vc mailing list