From b9ad4a000e254f5032914b520234cb23290c8aae Mon Sep 17 00:00:00 2001 From: "chao.an" Date: Mon, 29 Jun 2020 16:26:48 +0800 Subject: [PATCH] binfmt/exec: allocate stack from internal Implement of nxtask_init() support stack allocation from internal Change-Id: I4885c5b901d90e57eb9d15d8bc1af32761584d19 Signed-off-by: chao.an --- binfmt/binfmt_execmodule.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/binfmt/binfmt_execmodule.c b/binfmt/binfmt_execmodule.c index c2764672bed..57a6fd0d1b4 100644 --- a/binfmt/binfmt_execmodule.c +++ b/binfmt/binfmt_execmodule.c @@ -117,7 +117,6 @@ int exec_module(FAR const struct binary_s *binp) #if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL) save_addrenv_t oldenv; #endif - FAR void *stack; pid_t pid; int ret; @@ -151,27 +150,17 @@ int exec_module(FAR const struct binary_s *binp) } #endif - /* Allocate the stack for the new 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. - */ + /* Note that tcb->flags are not modified. 0=normal task */ - stack = kumm_malloc(binp->stacksize); - if (!stack) - { - ret = -ENOMEM; - goto errout_with_addrenv; - } + /* tcb->flags |= TCB_FLAG_TTYPE_TASK; */ /* Initialize the task */ 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) { berr("nxtask_init() failed: %d\n", ret); - kumm_free(stack); goto errout_with_addrenv; } @@ -183,10 +172,6 @@ int exec_module(FAR const 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) /* Allocate the kernel stack */ @@ -273,7 +258,6 @@ int exec_module(FAR const struct binary_s *binp) errout_with_tcbinit: tcb->cmn.stack_alloc_ptr = NULL; nxsched_release_tcb(&tcb->cmn, TCB_FLAG_TTYPE_TASK); - kumm_free(stack); return ret; #endif