mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 07:12:54 +08:00
sched/spawn: remove spawn proxy thread to simplify task/posix_spawn()
The spawn proxy thread is a special existence in NuttX, usually some developers spend a lot of time on stack overflow of spawn proxy thread: https://github.com/apache/nuttx/issues/9046 https://github.com/apache/nuttx/pull/9081 In order to avoid similar issues, this PR will remove spawn proxy thread to simplify the process of task/posix_spawn(). 1. Postpone the related processing of spawn file actions until after task_init() 2. Delete the temporary thread of spawn proxy and related global variables Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
@@ -62,6 +62,7 @@
|
||||
* exported by the caller and made available for linking the
|
||||
* module into the system.
|
||||
* nexports - The number of symbols in the exports table.
|
||||
* actions - The spawn file actions
|
||||
* attr - The spawn attributes.
|
||||
*
|
||||
* Returned Value:
|
||||
@@ -72,7 +73,8 @@
|
||||
|
||||
int exec_spawn(FAR const char *filename, FAR char * const *argv,
|
||||
FAR char * const *envp, FAR const struct symtab_s *exports,
|
||||
int nexports, FAR const posix_spawnattr_t *attr)
|
||||
int nexports, FAR const posix_spawn_file_actions_t *actions,
|
||||
FAR const posix_spawnattr_t *attr)
|
||||
{
|
||||
FAR struct binary_s *bin;
|
||||
int pid;
|
||||
@@ -128,7 +130,7 @@ int exec_spawn(FAR const char *filename, FAR char * const *argv,
|
||||
|
||||
/* Then start the module */
|
||||
|
||||
pid = exec_module(bin, filename, argv, envp);
|
||||
pid = exec_module(bin, filename, argv, envp, actions);
|
||||
if (pid < 0)
|
||||
{
|
||||
ret = pid;
|
||||
@@ -239,7 +241,7 @@ int exec(FAR const char *filename, FAR char * const *argv,
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = exec_spawn(filename, argv, envp, exports, nexports, NULL);
|
||||
ret = exec_spawn(filename, argv, envp, exports, nexports, NULL, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
set_errno(-ret);
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/sched.h>
|
||||
#include <nuttx/spawn.h>
|
||||
#include <nuttx/binfmt/binfmt.h>
|
||||
|
||||
#include "binfmt.h"
|
||||
@@ -113,7 +114,8 @@ static void exec_ctors(FAR void *arg)
|
||||
|
||||
int exec_module(FAR struct binary_s *binp,
|
||||
FAR const char *filename, FAR char * const *argv,
|
||||
FAR char * const *envp)
|
||||
FAR char * const *envp,
|
||||
FAR const posix_spawn_file_actions_t *actions)
|
||||
{
|
||||
FAR struct task_tcb_s *tcb;
|
||||
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
|
||||
@@ -216,6 +218,17 @@ int exec_module(FAR struct binary_s *binp,
|
||||
binfmt_freeargv(argv);
|
||||
binfmt_freeenv(envp);
|
||||
|
||||
/* Perform file actions */
|
||||
|
||||
if (actions != NULL)
|
||||
{
|
||||
ret = spawn_file_actions(&tcb->cmn, actions);
|
||||
if (ret < 0)
|
||||
{
|
||||
goto errout_with_tcbinit;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_ARCH_KERNEL_STACK)
|
||||
/* Allocate the kernel stack */
|
||||
|
||||
@@ -283,7 +296,6 @@ int exec_module(FAR struct binary_s *binp,
|
||||
|
||||
return (int)pid;
|
||||
|
||||
#if defined(CONFIG_ARCH_ADDRENV) || defined(CONFIG_ARCH_VMA_MAPPING)
|
||||
errout_with_tcbinit:
|
||||
#ifndef CONFIG_BUILD_KERNEL
|
||||
if (binp->stackaddr != NULL)
|
||||
@@ -294,7 +306,6 @@ errout_with_tcbinit:
|
||||
|
||||
nxtask_uninit(tcb);
|
||||
return ret;
|
||||
#endif
|
||||
|
||||
errout_with_addrenv:
|
||||
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
|
||||
|
||||
Reference in New Issue
Block a user