mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
Revert "Exec: Support run exec in current task"
This reverts commit 670c245ff2.
This commit is contained in:
committed by
Petro Karashchenko
parent
b1bbbfa084
commit
1b97c05ab5
@@ -36,7 +36,6 @@
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/sched.h>
|
||||
#include <sched/sched.h>
|
||||
#include <nuttx/spawn.h>
|
||||
#include <nuttx/binfmt/binfmt.h>
|
||||
|
||||
@@ -97,91 +96,6 @@ static void exec_ctors(FAR void *arg)
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: exec_swap
|
||||
*
|
||||
* Description:
|
||||
* swap the pid of tasks, and reverse parent-child relationship.
|
||||
*
|
||||
* Input Parameters:
|
||||
* ptcb - parent task tcb.
|
||||
* chtcb - child task tcb.
|
||||
*
|
||||
* Returned Value:
|
||||
* none
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void exec_swap(FAR struct tcb_s *ptcb, FAR struct tcb_s *chtcb)
|
||||
{
|
||||
int pndx;
|
||||
int chndx;
|
||||
pid_t pid;
|
||||
irqstate_t flags;
|
||||
#ifdef HAVE_GROUP_MEMBERS
|
||||
FAR pid_t *tg_members;
|
||||
#endif
|
||||
#ifdef CONFIG_SCHED_HAVE_PARENT
|
||||
# ifdef CONFIG_SCHED_CHILD_STATUS
|
||||
FAR struct child_status_s *tg_children;
|
||||
# else
|
||||
uint16_t tg_nchildren;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
DEBUGASSERT(ptcb);
|
||||
DEBUGASSERT(chtcb);
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
||||
pndx = PIDHASH(ptcb->pid);
|
||||
chndx = PIDHASH(chtcb->pid);
|
||||
|
||||
DEBUGASSERT(g_pidhash[pndx]);
|
||||
DEBUGASSERT(g_pidhash[chndx]);
|
||||
|
||||
/* Exchange g_pidhash index */
|
||||
|
||||
g_pidhash[pndx] = chtcb;
|
||||
g_pidhash[chndx] = ptcb;
|
||||
|
||||
/* Exchange pid */
|
||||
|
||||
pid = chtcb->pid;
|
||||
chtcb->pid = ptcb->pid;
|
||||
ptcb->pid = pid;
|
||||
|
||||
/* Exchange group info. This will reverse parent-child relationship */
|
||||
|
||||
pid = chtcb->group->tg_pid;
|
||||
chtcb->group->tg_pid = ptcb->group->tg_pid;
|
||||
ptcb->group->tg_pid = pid;
|
||||
|
||||
pid = chtcb->group->tg_ppid;
|
||||
chtcb->group->tg_ppid = ptcb->group->tg_ppid;
|
||||
ptcb->group->tg_ppid = pid;
|
||||
|
||||
#ifdef HAVE_GROUP_MEMBERS
|
||||
tg_members = chtcb->group->tg_members;
|
||||
chtcb->group->tg_members = ptcb->group->tg_members;
|
||||
ptcb->group->tg_members = tg_members;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SCHED_HAVE_PARENT
|
||||
# ifdef CONFIG_SCHED_CHILD_STATUS
|
||||
tg_children = chtcb->group->tg_children;
|
||||
chtcb->group->tg_children = ptcb->group->tg_children;
|
||||
ptcb->group->tg_children = tg_children;
|
||||
# else
|
||||
tg_nchildren = chtcb->group->tg_nchildren;
|
||||
chtcb->group->tg_nchildren = ptcb->group->tg_nchildren;
|
||||
ptcb->group->tg_nchildren = tg_nchildren;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@@ -202,8 +116,7 @@ static void exec_swap(FAR struct tcb_s *ptcb, FAR struct tcb_s *chtcb)
|
||||
int exec_module(FAR struct binary_s *binp,
|
||||
FAR const char *filename, FAR char * const *argv,
|
||||
FAR char * const *envp,
|
||||
FAR const posix_spawn_file_actions_t *actions,
|
||||
bool spawn)
|
||||
FAR const posix_spawn_file_actions_t *actions)
|
||||
{
|
||||
FAR struct task_tcb_s *tcb;
|
||||
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
|
||||
@@ -379,11 +292,6 @@ int exec_module(FAR struct binary_s *binp,
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!spawn)
|
||||
{
|
||||
exec_swap(this_task(), (FAR struct tcb_s *)tcb);
|
||||
}
|
||||
|
||||
/* Then activate the task at the provided priority */
|
||||
|
||||
nxtask_activate((FAR struct tcb_s *)tcb);
|
||||
|
||||
Reference in New Issue
Block a user