summaryrefslogtreecommitdiff
path: root/nuttx/sched/group
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 /nuttx/sched/group
parentdb977bce4ca94e94e5374b152fa6fa931e2079e2 (diff)
downloadpx4-nuttx-e7723401ed547d5859bdbf4804a5c1f056858a6b.tar.gz
px4-nuttx-e7723401ed547d5859bdbf4804a5c1f056858a6b.tar.bz2
px4-nuttx-e7723401ed547d5859bdbf4804a5c1f056858a6b.zip
ADDRENV: Use a group flag to determine if there is an address environment (instead of the thread type)
Diffstat (limited to 'nuttx/sched/group')
-rw-r--r--nuttx/sched/group/group_addrenv.c23
-rw-r--r--nuttx/sched/group/group_leave.c4
2 files changed, 19 insertions, 8 deletions
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)