diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-01-25 23:21:27 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-01-25 23:21:27 +0000 |
commit | 239e2808cca6ee4c356d087bc83889fc57e64307 (patch) | |
tree | fd3a16f87e715df6729c7966a230f93214e98e20 /nuttx/sched/group_create.c | |
parent | fdaa22ed2d565e49983e956bc056f1e0797bd9a9 (diff) | |
download | px4-firmware-239e2808cca6ee4c356d087bc83889fc57e64307.tar.gz px4-firmware-239e2808cca6ee4c356d087bc83889fc57e64307.tar.bz2 px4-firmware-239e2808cca6ee4c356d087bc83889fc57e64307.zip |
Move environment variables in the task group structure
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5565 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched/group_create.c')
-rw-r--r-- | nuttx/sched/group_create.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/nuttx/sched/group_create.c b/nuttx/sched/group_create.c index 4612ae8c5..da91fa065 100644 --- a/nuttx/sched/group_create.c +++ b/nuttx/sched/group_create.c @@ -46,6 +46,9 @@ #include <nuttx/kmalloc.h> +#include "group_internal.h" +#include "env_internal.h" + #ifdef HAVE_TASK_GROUP /***************************************************************************** @@ -97,12 +100,29 @@ int group_allocate(FAR _TCB *tcb) { + 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)); - return tcb->group ? OK : -ENOMEM; + if (!tcb->group) + { + return -ENOMEM; + } + + /* Duplicate the parent tasks envionment */ + + ret = env_dup(tcb); + if (ret < 0) + { + kfree(tcb->group); + tcb->group = NULL; + return ret; + } + + return OK; } /***************************************************************************** @@ -128,12 +148,12 @@ int group_allocate(FAR _TCB *tcb) int group_initialize(FAR _TCB *tcb) { -#ifdef HAVE_GROUP_MEMBERS FAR struct task_group_s *group; DEBUGASSERT(tcb && tcb->group); group = tcb->group; +#ifdef HAVE_GROUP_MEMBERS /* Allocate space to hold GROUP_INITIAL_MEMBERS members of the group */ group->tg_members = (FAR pid_t *)kmalloc(GROUP_INITIAL_MEMBERS*sizeof(pid_t)); |