summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-08-27 09:37:28 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-08-27 09:37:28 -0600
commite7723401ed547d5859bdbf4804a5c1f056858a6b (patch)
tree1e9a4cc2bb9939f31a9dad5d68cb0b03bc4b38eb
parentdb977bce4ca94e94e5374b152fa6fa931e2079e2 (diff)
downloadnuttx-e7723401ed547d5859bdbf4804a5c1f056858a6b.tar.gz
nuttx-e7723401ed547d5859bdbf4804a5c1f056858a6b.tar.bz2
nuttx-e7723401ed547d5859bdbf4804a5c1f056858a6b.zip
ADDRENV: Use a group flag to determine if there is an address environment (instead of the thread type)
-rw-r--r--nuttx/binfmt/binfmt_execmodule.c4
-rw-r--r--nuttx/include/nuttx/sched.h1
-rw-r--r--nuttx/sched/group/group_addrenv.c23
-rw-r--r--nuttx/sched/group/group_leave.c4
4 files changed, 24 insertions, 8 deletions
diff --git a/nuttx/binfmt/binfmt_execmodule.c b/nuttx/binfmt/binfmt_execmodule.c
index 5d49acf74..07c507233 100644
--- a/nuttx/binfmt/binfmt_execmodule.c
+++ b/nuttx/binfmt/binfmt_execmodule.c
@@ -215,6 +215,10 @@ int exec_module(FAR const struct binary_s *binp)
bdbg("ERROR: up_addrenv_clone() failed: %d\n", ret);
goto errout_with_stack;
}
+
+ /* Mark that this group has an address environment */
+
+ tcb->cmn.group->tg_flags |= GROUP_FLAG_ADDRENV;
#endif
#ifdef CONFIG_BINFMT_CONSTRUCTORS
diff --git a/nuttx/include/nuttx/sched.h b/nuttx/include/nuttx/sched.h
index 7a4004d9a..ecff5de23 100644
--- a/nuttx/include/nuttx/sched.h
+++ b/nuttx/include/nuttx/sched.h
@@ -133,6 +133,7 @@
/* Values for struct task_group tg_flags */
#define GROUP_FLAG_NOCLDWAIT (1 << 0) /* Bit 0: Do not retain child exit status */
+#define GROUP_FLAG_ADDRENV (1 << 1) /* Bit 1: Group has an address environment */
/* Values for struct child_status_s ch_flags */
diff --git a/nuttx/sched/group/group_addrenv.c b/nuttx/sched/group/group_addrenv.c
index 48e61fd4a..35dcab9ca 100644
--- a/nuttx/sched/group/group_addrenv.c
+++ b/nuttx/sched/group/group_addrenv.c
@@ -110,16 +110,22 @@ int group_addrenv(FAR struct tcb_s *tcb)
DEBUGASSERT(tcb && tcb->group);
group = tcb->group;
- /* What is the ID of the group of the new thread to run? Use zero if the
- * group is a kernel thread.
- */
+ /* Does the group have an address environment? */
- gid = 0;
- if ((tcb->flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_KERNEL)
+ if ((group->tg_flags & GROUP_FLAG_ADDRENV) == 0)
{
- gid = group->tg_gid;
+ /* No... just return perhaps leaving a different address environment
+ * intact.
+ */
+
+ return OK;
}
+ /* Get the ID of the group that needs the address environment */
+
+ gid = group->tg_gid;
+ DEBUGASSERT(gid != 0);
+
/* Are we going to change address environments? */
flags = irqsave();
@@ -129,10 +135,11 @@ int group_addrenv(FAR struct tcb_s *tcb)
if (g_gid_current != 0)
{
- /* Find the old group this this ID */
+ /* Find the old group with this ID. */
oldgroup = group_findbygid(g_gid_current);
- DEBUGASSERT(oldgroup);
+ DEBUGASSERT(oldgroup &&
+ (oldgroup->tg_flags & GROUP_FLAG_ADDRENV) != 0);
if (oldgroup)
{
diff --git a/nuttx/sched/group/group_leave.c b/nuttx/sched/group/group_leave.c
index e3606f2ee..403fe4c95 100644
--- a/nuttx/sched/group/group_leave.c
+++ b/nuttx/sched/group/group_leave.c
@@ -212,6 +212,10 @@ static inline void group_release(FAR struct task_group_s *group)
/* Destroy the group address environment */
(void)up_addrenv_destroy(&group->addrenv);
+
+ /* Mark no address environment */
+
+ g_gid_current = 0;
#endif
#if defined(HAVE_GROUP_MEMBERS) || defined(CONFIG_ARCH_ADDRENV)