sched/task: Simplify the syscall handling of task_spawn

It's better to save one argument by returning pid directly.
This change also follow the convention of task_create.
BTW, it is reasonable to adjust the function prototype a
little bit from both implementation and consistency since
task_spawn is NuttX specific API.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao
2021-05-12 11:34:50 +08:00
committed by Masayuki Ishikawa
parent 72d2fc547e
commit ae216cf9e9
8 changed files with 34 additions and 178 deletions
-24
View File
@@ -88,27 +88,6 @@ struct spawn_open_file_action_s
#define SIZEOF_OPEN_FILE_ACTION_S(n) \
(sizeof(struct spawn_open_file_action_s) + (n))
#ifdef CONFIG_LIB_SYSCALL
/* task_spawn() and posix_spawn() are NuttX OS interfaces. In PROTECTED and
* KERNEL build modes, then can be reached from applications only via a
* system call. Currently, the number of parameters in a system call is
* limited to six; these spawn function have seven parameters. Rather than
* extend the maximum number of parameters across all architectures, I opted
* instead to marshal the seven parameters into the following structure:
*/
struct spawn_syscall_parms_s
{
FAR pid_t *pid;
FAR const char *name;
main_t entry;
FAR const posix_spawn_file_actions_t *file_actions;
FAR const posix_spawnattr_t *attr;
FAR char * const *argv;
FAR char * const *envp;
};
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
@@ -120,9 +99,6 @@ extern "C"
void add_file_action(FAR posix_spawn_file_actions_t *file_action,
FAR struct spawn_general_file_action_s *entry);
#if defined(CONFIG_LIB_SYSCALL) && !defined(CONFIG_BUILD_KERNEL)
int nx_task_spawn(FAR const struct spawn_syscall_parms_s *parms);
#endif
#ifdef __cplusplus
}
+1 -1
View File
@@ -147,7 +147,7 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path,
* 'name'.
*/
int task_spawn(FAR pid_t *pid, FAR const char *name, main_t entry,
int task_spawn(FAR const char *name, main_t entry,
FAR const posix_spawn_file_actions_t *file_actions,
FAR const posix_spawnattr_t *attr,
FAR char * const argv[], FAR char * const envp[]);
+1 -3
View File
@@ -85,9 +85,7 @@ SYSCALL_LOOKUP(sem_wait, 1)
#ifndef CONFIG_BUILD_KERNEL
SYSCALL_LOOKUP(task_create, 5)
#ifdef CONFIG_LIB_SYSCALL
SYSCALL_LOOKUP(nx_task_spawn, 1)
#endif
SYSCALL_LOOKUP(task_spawn, 6)
#else
SYSCALL_LOOKUP(pgalloc, 2)
#endif