summaryrefslogtreecommitdiff
path: root/nuttx/sched/sched_waitpid.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-02-04 16:02:20 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-02-04 16:02:20 +0000
commitc94d7c870c456005b3e87d71acba8f7f9ea2b5ec (patch)
tree982d75559dbb2fc6f53a4e8d090d40ef5c9e0f80 /nuttx/sched/sched_waitpid.c
parentc13bd69be3d117b359275bcf3b2d631bb19bd597 (diff)
downloadpx4-nuttx-c94d7c870c456005b3e87d71acba8f7f9ea2b5ec.tar.gz
px4-nuttx-c94d7c870c456005b3e87d71acba8f7f9ea2b5ec.tar.bz2
px4-nuttx-c94d7c870c456005b3e87d71acba8f7f9ea2b5ec.zip
Move waitpid() data structures to task group; The caller of waitpid() is now only awakened when the final thread of the task group exits
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5608 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched/sched_waitpid.c')
-rw-r--r--nuttx/sched/sched_waitpid.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/nuttx/sched/sched_waitpid.c b/nuttx/sched/sched_waitpid.c
index e44ef6e21..e79dded4c 100644
--- a/nuttx/sched/sched_waitpid.c
+++ b/nuttx/sched/sched_waitpid.c
@@ -182,7 +182,8 @@
#ifndef CONFIG_SCHED_HAVE_PARENT
pid_t waitpid(pid_t pid, int *stat_loc, int options)
{
- _TCB *ctcb;
+ FAR _TCB *ctcb;
+ FAR struct task_group_s *group;
bool mystat;
int err;
int ret;
@@ -212,21 +213,26 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
goto errout_with_errno;
}
+ /* The the task group corresponding to this PID */
+
+ group = ctcb->group;
+ DEBUGASSERT(group);
+
/* "If more than one thread is suspended in waitpid() awaiting termination of
* the same process, exactly one thread will return the process status at the
* time of the target process termination." Hmmm.. what do we return to the
* others?
*/
- if (stat_loc != NULL && ctcb->stat_loc == NULL)
+ if (stat_loc != NULL && group->tg_statloc == NULL)
{
- ctcb->stat_loc = stat_loc;
- mystat = true;
+ group->tg_statloc = stat_loc;
+ mystat = true;
}
/* Then wait for the task to exit */
- ret = sem_wait(&ctcb->exitsem);
+ ret = sem_wait(&group->tg_exitsem);
if (ret < 0)
{
/* Unlock pre-emption and return the ERROR (sem_wait has already set
@@ -236,7 +242,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
if (mystat)
{
- ctcb->stat_loc = NULL;
+ group->tg_statloc = NULL;
}
goto errout;