You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/12/24 14:23:41 UTC

[incubator-nuttx] 02/03: init: use exec_spawn instead of exec

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 0bb32f27c080a7b67b5913839e0d44a03d434ac2
Author: ligd <li...@xiaomi.com>
AuthorDate: Mon Dec 20 12:30:57 2021 +0800

    init: use exec_spawn instead of exec
    
    Signed-off-by: ligd <li...@xiaomi.com>
---
 sched/Kconfig           |  4 ++++
 sched/init/nx_bringup.c | 17 +++++++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/sched/Kconfig b/sched/Kconfig
index 5843b34..1f94a0f 100644
--- a/sched/Kconfig
+++ b/sched/Kconfig
@@ -347,6 +347,10 @@ config INIT_ENTRYPOINT
 		applications this is of the form 'app_main' where 'app' is the application
 		name. If not defined, INIT_ENTRYPOINT defaults to "main".
 
+config INIT_ENTRYNAME
+	string "Application entry name"
+	default INIT_ENTRYPOINT
+
 endif # INIT_ENTRY
 
 if INIT_FILE
diff --git a/sched/init/nx_bringup.c b/sched/init/nx_bringup.c
index 99c94c2..8ec1d74 100644
--- a/sched/init/nx_bringup.c
+++ b/sched/init/nx_bringup.c
@@ -234,6 +234,9 @@ static inline void nx_start_application(void)
   FAR char *const *argv = NULL;
 #endif
   int ret;
+#ifdef CONFIG_INIT_FILE
+  posix_spawnattr_t attr;
+#endif
 
 #ifdef CONFIG_BOARD_LATE_INITIALIZE
   /* Perform any last-minute, board-specific initialization, if so
@@ -255,11 +258,11 @@ static inline void nx_start_application(void)
 
 #ifdef CONFIG_BUILD_PROTECTED
   DEBUGASSERT(USERSPACE->us_entrypoint != NULL);
-  ret = nxtask_create("init", CONFIG_INIT_PRIORITY,
+  ret = nxtask_create(CONFIG_INIT_ENTRYNAME, CONFIG_INIT_PRIORITY,
                       CONFIG_INIT_STACKSIZE,
                       USERSPACE->us_entrypoint, argv);
 #else
-  ret = nxtask_create("init", CONFIG_INIT_PRIORITY,
+  ret = nxtask_create(CONFIG_INIT_ENTRYNAME, CONFIG_INIT_PRIORITY,
                       CONFIG_INIT_STACKSIZE,
                       (main_t)CONFIG_INIT_ENTRYPOINT, argv);
 #endif
@@ -283,8 +286,14 @@ static inline void nx_start_application(void)
 
   sinfo("Starting init task: %s\n", CONFIG_INIT_FILEPATH);
 
-  ret = exec(CONFIG_INIT_FILEPATH, argv,
-             CONFIG_INIT_SYMTAB, CONFIG_INIT_NEXPORTS);
+  posix_spawnattr_init(&attr);
+
+  attr.priority  = CONFIG_INIT_PRIORITY;
+#ifndef CONFIG_ARCH_ADDRENV
+  attr.stacksize = CONFIG_INIT_STACKSIZE;
+#endif
+  ret = exec_spawn(CONFIG_INIT_FILEPATH, argv,
+                   CONFIG_INIT_SYMTAB, CONFIG_INIT_NEXPORTS, &attr);
   DEBUGASSERT(ret >= 0);
 #endif