Launch the initial task through task_spawn instead of nxtask_create

to share the code with the code path of posix_spawn

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-10-30 00:30:23 +08:00 committed by Petro Karashchenko
parent 926e296d48
commit 1280a2a8f9
2 changed files with 20 additions and 22 deletions

View File

@ -1604,21 +1604,20 @@ static void uart_launch_worker(void *arg)
nxsched_foreach(uart_launch_foreach, &found);
if (!found)
{
#ifdef CONFIG_TTY_LAUNCH_ENTRY
nxtask_create(CONFIG_TTY_LAUNCH_ENTRYNAME,
CONFIG_TTY_LAUNCH_PRIORITY,
NULL, CONFIG_TTY_LAUNCH_STACKSIZE,
CONFIG_TTY_LAUNCH_ENTRYPOINT,
argv, NULL);
#else
posix_spawnattr_t attr;
posix_spawnattr_init(&attr);
attr.priority = CONFIG_TTY_LAUNCH_PRIORITY;
attr.stacksize = CONFIG_TTY_LAUNCH_STACKSIZE;
exec_spawn(CONFIG_TTY_LAUNCH_FILEPATH, argv, NULL, 0, &attr);
#ifdef CONFIG_TTY_LAUNCH_ENTRY
task_spawn(CONFIG_TTY_LAUNCH_ENTRYNAME,
CONFIG_TTY_LAUNCH_ENTRYPOINT,
NULL, &attr, argv, NULL);
#else
exec_spawn(CONFIG_TTY_LAUNCH_FILEPATH, argv, NULL, NULL, 0, &attr);
#endif
posix_spawnattr_destroy(&attr);
}
}

View File

@ -234,9 +234,7 @@ static inline void nx_start_application(void)
# endif
NULL,
};
#endif
#ifdef CONFIG_INIT_FILE
posix_spawnattr_t attr;
#endif
int ret;
@ -249,6 +247,10 @@ static inline void nx_start_application(void)
board_late_initialize();
#endif
posix_spawnattr_init(&attr);
attr.priority = CONFIG_INIT_PRIORITY;
attr.stacksize = CONFIG_INIT_STACKSIZE;
#if defined(CONFIG_INIT_ENTRY)
/* Start the application initialization task. In a flat build, this is
@ -261,16 +263,14 @@ static inline void nx_start_application(void)
# ifdef CONFIG_BUILD_PROTECTED
DEBUGASSERT(USERSPACE->us_entrypoint != NULL);
ret = nxtask_create(CONFIG_INIT_ENTRYNAME, CONFIG_INIT_PRIORITY,
NULL, CONFIG_INIT_STACKSIZE,
USERSPACE->us_entrypoint, argv, NULL);
ret = task_spawn(CONFIG_INIT_ENTRYNAME,
USERSPACE->us_entrypoint,
NULL, &attr, argv, NULL);
# else
ret = nxtask_create(CONFIG_INIT_ENTRYNAME, CONFIG_INIT_PRIORITY,
NULL, CONFIG_INIT_STACKSIZE,
CONFIG_INIT_ENTRYPOINT, argv, NULL);
ret = task_spawn(CONFIG_INIT_ENTRYNAME,
CONFIG_INIT_ENTRYPOINT,
NULL, &attr, argv, NULL);
# endif
DEBUGASSERT(ret > 0);
#elif defined(CONFIG_INIT_FILE)
# ifdef CONFIG_INIT_MOUNT
@ -296,10 +296,9 @@ static inline void nx_start_application(void)
ret = exec_spawn(CONFIG_INIT_FILEPATH, argv, NULL,
CONFIG_INIT_SYMTAB, CONFIG_INIT_NEXPORTS, &attr);
DEBUGASSERT(ret >= 0);
#endif
UNUSED(ret);
posix_spawnattr_destroy(&attr);
DEBUGASSERT(ret > 0);
}
/****************************************************************************