ADDRENV: Use a group flag to determine if there is an address environment (instead of the thread type)

This commit is contained in:
Gregory Nutt 2014-08-27 09:37:28 -06:00
parent 355bef617f
commit ad53cabf34
4 changed files with 24 additions and 8 deletions

View File

@ -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

View File

@ -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 */

View File

@ -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)
{

View File

@ -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)