diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-02-03 16:43:58 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-02-03 16:43:58 +0000 |
commit | 32dde889e28f1e15c4a97f3e701800ba22ab849d (patch) | |
tree | 83fc8fbb0fcef9302298d1ccb819cfba26ec8825 /nuttx/sched/group_create.c | |
parent | 0066db82f921ad84a9017242396e37259f3d71f4 (diff) | |
download | px4-nuttx-32dde889e28f1e15c4a97f3e701800ba22ab849d.tar.gz px4-nuttx-32dde889e28f1e15c4a97f3e701800ba22ab849d.tar.bz2 px4-nuttx-32dde889e28f1e15c4a97f3e701800ba22ab849d.zip |
Move pthread join and key creation data into the task group
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5602 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched/group_create.c')
-rw-r--r-- | nuttx/sched/group_create.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/nuttx/sched/group_create.c b/nuttx/sched/group_create.c index 24f6923aa..58eb60606 100644 --- a/nuttx/sched/group_create.c +++ b/nuttx/sched/group_create.c @@ -176,36 +176,47 @@ void group_assigngid(FAR struct task_group_s *group) int group_allocate(FAR _TCB *tcb) { + FAR struct task_group_s *group; int ret; DEBUGASSERT(tcb && !tcb->group); /* Allocate the group structure and assign it to the TCB */ - tcb->group = (FAR struct task_group_s *)kzalloc(sizeof(struct task_group_s)); - if (!tcb->group) + group = (FAR struct task_group_s *)kzalloc(sizeof(struct task_group_s)); + if (!group) { return -ENOMEM; } + /* Attach the group to the TCB */ + + tcb->group = group; + /* Assign the group a unique ID. If g_gidcounter were to wrap before we * finish with task creation, that would be a problem. */ #ifdef HAVE_GROUP_MEMBERS - group_assigngid(tcb->group); + group_assigngid(group); #endif /* Duplicate the parent tasks envionment */ - ret = env_dup(tcb->group); + ret = env_dup(group); if (ret < 0) { - kfree(tcb->group); + kfree(group); tcb->group = NULL; return ret; } + /* Initialize the pthread join semaphore */ + +#ifndef CONFIG_DISABLE_PTHREAD + (void)sem_init(&group->tg_joinsem, 0, 1); +#endif + return OK; } |