summaryrefslogtreecommitdiff
path: root/nuttx/sched/pthread_condtimedwait.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-02-05 19:50:37 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-02-05 19:50:37 +0000
commit0d9fb476ea6f347c48a3ac8c2d98251467421203 (patch)
treee98b731e1ff4298ed906fde23198fb4d9a9d61a9 /nuttx/sched/pthread_condtimedwait.c
parent70121d6ca8fd0e48f35b3ccb52e3b960e64df6c2 (diff)
downloadpx4-nuttx-0d9fb476ea6f347c48a3ac8c2d98251467421203.tar.gz
px4-nuttx-0d9fb476ea6f347c48a3ac8c2d98251467421203.tar.bz2
px4-nuttx-0d9fb476ea6f347c48a3ac8c2d98251467421203.zip
Moving pending signals to task group; Logic to recover some MQ resources on pthread_cacancel or task_delete; Now obeys rules for delivering signals to a process with threads
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5613 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched/pthread_condtimedwait.c')
-rw-r--r--nuttx/sched/pthread_condtimedwait.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/nuttx/sched/pthread_condtimedwait.c b/nuttx/sched/pthread_condtimedwait.c
index 25f86d813..3914f40ff 100644
--- a/nuttx/sched/pthread_condtimedwait.c
+++ b/nuttx/sched/pthread_condtimedwait.c
@@ -52,6 +52,7 @@
#include "os_internal.h"
#include "pthread_internal.h"
#include "clock_internal.h"
+#include "sig_internal.h"
/****************************************************************************
* Definitions
@@ -94,6 +95,48 @@
static void pthread_condtimedout(int argc, uint32_t pid, uint32_t signo)
{
+#ifdef HAVE_GROUP_MEMBERS
+
+ FAR struct tcb_s *tcb;
+ siginfo_t info;
+
+ /* The logic below if equivalent to sigqueue(), but uses sig_tcbdispatch()
+ * instead of sig_dispatch(). This avoids the group signal deliver logic
+ * and assures, instead, that the signal is delivered specifically to this
+ * thread that is known to be waiting on the signal.
+ */
+
+ /* Get the waiting TCB. sched_gettcb() might return NULL if the task has
+ * exited for some reason.
+ */
+
+ tcb = sched_gettcb((pid_t)pid);
+ if (tcb)
+ {
+ /* Create the siginfo structure */
+
+ info.si_signo = signo;
+ info.si_code = SI_QUEUE;
+ info.si_value.sival_ptr = NULL;
+#ifdef CONFIG_SCHED_HAVE_PARENT
+ info.si_pid = (pid_t)pid;
+ info.si_status = OK;
+#endif
+
+ /* Process the receipt of the signal. The scheduler is not locked as
+ * is normally the case when this function is called because we are in
+ * a watchdog timer interrupt handler.
+ */
+
+ (void)sig_tcbdispatch(tcb, &info);
+ }
+
+#else /* HAVE_GROUP_MEMBERS */
+
+ /* Things are a little easier if there are not group members. We can just
+ * use sigqueue().
+ */
+
#ifdef CONFIG_CAN_PASS_STRUCTS
union sigval value;
@@ -104,6 +147,8 @@ static void pthread_condtimedout(int argc, uint32_t pid, uint32_t signo)
#else
(void)sigqueue((int)pid, (int)signo, NULL);
#endif
+
+#endif /* HAVE_GROUP_MEMBERS */
}
/****************************************************************************