sched: Move argv from tcb_s to task_info_s

argv is allocated from stack and then belong to userspace,
so task_info_s is a best location to hold this information.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao
2021-11-29 11:00:27 +08:00
committed by Xiang Xiao
parent 3d6a5a2d0d
commit 1af8cd4de8
12 changed files with 35 additions and 45 deletions
+1 -1
View File
@@ -457,7 +457,6 @@ void nx_start(void)
g_idleargv[i][0] = (FAR char *)g_idlename;
#endif /* CONFIG_TASK_NAME_SIZE */
g_idleargv[i][1] = NULL;
g_idletcb[i].argv = &g_idleargv[i][0];
/* Then add the idle task's TCB to the head of the current ready to
* run list.
@@ -563,6 +562,7 @@ void nx_start(void)
/* Allocate the IDLE group */
DEBUGVERIFY(group_allocate(&g_idletcb[i], g_idletcb[i].cmn.flags));
g_idletcb[i].cmn.group->tg_info->argv = &g_idleargv[i][0];
#ifdef CONFIG_SMP
/* Create a stack for all CPU IDLE threads (except CPU0 which already
+1 -1
View File
@@ -612,7 +612,7 @@ static int nxtask_setup_stackargs(FAR struct task_tcb_s *tcb,
*/
stackargv[argc + 1] = NULL;
tcb->argv = stackargv;
tcb->cmn.group->tg_info->argv = stackargv;
return OK;
}
+6 -4
View File
@@ -101,7 +101,7 @@ void nxtask_start(void)
*/
argc = 1;
while (tcb->argv[argc])
while (tcb->cmn.group->tg_info->argv[argc])
{
/* Increment the number of args. Here is a sanity check to
* prevent running away with an unterminated argv[] list.
@@ -122,14 +122,16 @@ void nxtask_start(void)
if ((tcb->cmn.flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_KERNEL)
{
exitcode = tcb->cmn.entry.main(argc, tcb->argv);
exitcode = tcb->cmn.entry.main(argc, tcb->cmn.group->tg_info->argv);
}
else
{
#ifdef CONFIG_BUILD_FLAT
nxtask_startup(tcb->cmn.entry.main, argc, tcb->argv);
nxtask_startup(tcb->cmn.entry.main, argc,
tcb->cmn.group->tg_info->argv);
#else
up_task_start(tcb->cmn.entry.main, argc, tcb->argv);
up_task_start(tcb->cmn.entry.main, argc,
tcb->cmn.group->tg_info->argv);
#endif
}
+7 -7
View File
@@ -94,7 +94,7 @@
FAR struct task_tcb_s *nxtask_setup_vfork(start_t retaddr)
{
FAR struct tcb_s *ptcb = this_task();
FAR struct task_tcb_s *parent;
FAR struct tcb_s *parent;
FAR struct task_tcb_s *child;
FAR struct tls_info_s *info;
size_t stack_size;
@@ -111,7 +111,7 @@ FAR struct task_tcb_s *nxtask_setup_vfork(start_t retaddr)
/* Fork'ed from a kernel thread */
ttype = TCB_FLAG_TTYPE_KERNEL;
parent = (FAR struct task_tcb_s *)ptcb;
parent = ptcb;
}
else
{
@@ -120,12 +120,11 @@ FAR struct task_tcb_s *nxtask_setup_vfork(start_t retaddr)
ttype = TCB_FLAG_TTYPE_TASK;
if ((ptcb->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_TASK)
{
parent = (FAR struct task_tcb_s *)ptcb;
parent = ptcb;
}
else
{
parent = (FAR struct task_tcb_s *)
nxsched_get_tcb(ptcb->group->tg_pid);
parent = nxsched_get_tcb(ptcb->group->tg_pid);
if (parent == NULL)
{
ret = -ENOENT;
@@ -181,7 +180,7 @@ FAR struct task_tcb_s *nxtask_setup_vfork(start_t retaddr)
}
DEBUGASSERT(info == child->cmn.stack_alloc_ptr);
memcpy(info, parent->cmn.stack_alloc_ptr, sizeof(struct tls_info_s));
memcpy(info, parent->stack_alloc_ptr, sizeof(struct tls_info_s));
info->tl_task = child->cmn.group->tg_info;
up_tls_initialize(info);
@@ -206,7 +205,8 @@ FAR struct task_tcb_s *nxtask_setup_vfork(start_t retaddr)
/* Setup to pass parameters to the new task */
nxtask_setup_arguments(child, parent->argv[0], &parent->argv[1]);
nxtask_setup_arguments(child, parent->group->tg_info->argv[0],
&parent->group->tg_info->argv[1]);
/* Now we have enough in place that we can join the group */