mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 21:36:28 +08:00
binfmt/exec: allocate stack from internal
Implement of nxtask_init() support stack allocation from internal Change-Id: I4885c5b901d90e57eb9d15d8bc1af32761584d19 Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
@@ -117,7 +117,6 @@ int exec_module(FAR const struct binary_s *binp)
|
|||||||
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
|
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
|
||||||
save_addrenv_t oldenv;
|
save_addrenv_t oldenv;
|
||||||
#endif
|
#endif
|
||||||
FAR void *stack;
|
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -151,27 +150,17 @@ int exec_module(FAR const struct binary_s *binp)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Allocate the stack for the new task.
|
/* Note that tcb->flags are not modified. 0=normal task */
|
||||||
*
|
|
||||||
* REVISIT: This allocation is currently always from the user heap. That
|
|
||||||
* will need to change if/when we want to support dynamic stack allocation.
|
|
||||||
*/
|
|
||||||
|
|
||||||
stack = kumm_malloc(binp->stacksize);
|
/* tcb->flags |= TCB_FLAG_TTYPE_TASK; */
|
||||||
if (!stack)
|
|
||||||
{
|
|
||||||
ret = -ENOMEM;
|
|
||||||
goto errout_with_addrenv;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initialize the task */
|
/* Initialize the task */
|
||||||
|
|
||||||
ret = nxtask_init((FAR struct tcb_s *)tcb, binp->filename, binp->priority,
|
ret = nxtask_init((FAR struct tcb_s *)tcb, binp->filename, binp->priority,
|
||||||
stack, binp->stacksize, binp->entrypt, binp->argv);
|
NULL, binp->stacksize, binp->entrypt, binp->argv);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
berr("nxtask_init() failed: %d\n", ret);
|
berr("nxtask_init() failed: %d\n", ret);
|
||||||
kumm_free(stack);
|
|
||||||
goto errout_with_addrenv;
|
goto errout_with_addrenv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,10 +172,6 @@ int exec_module(FAR const struct binary_s *binp)
|
|||||||
|
|
||||||
binfmt_freeargv((FAR struct binary_s *)binp);
|
binfmt_freeargv((FAR struct binary_s *)binp);
|
||||||
|
|
||||||
/* Note that tcb->flags are not modified. 0=normal task */
|
|
||||||
|
|
||||||
/* tcb->flags |= TCB_FLAG_TTYPE_TASK; */
|
|
||||||
|
|
||||||
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
|
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
|
||||||
/* Allocate the kernel stack */
|
/* Allocate the kernel stack */
|
||||||
|
|
||||||
@@ -273,7 +258,6 @@ int exec_module(FAR const struct binary_s *binp)
|
|||||||
errout_with_tcbinit:
|
errout_with_tcbinit:
|
||||||
tcb->cmn.stack_alloc_ptr = NULL;
|
tcb->cmn.stack_alloc_ptr = NULL;
|
||||||
nxsched_release_tcb(&tcb->cmn, TCB_FLAG_TTYPE_TASK);
|
nxsched_release_tcb(&tcb->cmn, TCB_FLAG_TTYPE_TASK);
|
||||||
kumm_free(stack);
|
|
||||||
return ret;
|
return ret;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user