Skip to content

Commit

Permalink
sched/tls: drop ta_argv and g_idleargv
Browse files Browse the repository at this point in the history
- replaces `ta_argv` usage with `stackargs`
- drops `ta_argv` from `task_info_s`
- drops `g_idleargv` because idle is cared in `group_argvstr`

Signed-off-by: Yanfeng Liu <[email protected]>
  • Loading branch information
yf13 committed May 21, 2024
1 parent 4b52bda commit b949bca
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 43 deletions.
2 changes: 0 additions & 2 deletions include/nuttx/tls.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ struct pthread_atfork_s
struct task_info_s
{
mutex_t ta_lock;
int ta_argc; /* Number of arguments */
FAR char **ta_argv; /* Name+start-up parameters */
#if CONFIG_TLS_TASK_NELEM > 0
uintptr_t ta_telem[CONFIG_TLS_TASK_NELEM]; /* Task local storage elements */
#endif
Expand Down
5 changes: 2 additions & 3 deletions libs/libc/stdlib/lib_getprogname.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@

FAR const char *getprogname(void)
{
FAR struct task_info_s *info;
FAR struct tls_info_s *info = tls_get_info();

info = task_get_info();
return info->ta_argv[0];
return (((FAR const char *)info) + info->tl_size);
}
9 changes: 4 additions & 5 deletions sched/group/group_argvstr.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,11 @@ size_t group_argvstr(FAR struct tcb_s *tcb, FAR char *args, size_t size)
FAR struct addrenv_s *oldenv;
#endif

/* Perform sanity checks */
/* Sanity checks and idle tasks */

if (!tcb || !tcb->group || !tcb->group->tg_info)
if (!tcb || !tcb->group || !tcb->group->tg_info || size < 1 ||
is_idle_task(tcb))
{
/* Something is very wrong -> get out */

*args = '\0';
return 0;
}
Expand All @@ -90,7 +89,7 @@ size_t group_argvstr(FAR struct tcb_s *tcb, FAR char *args, size_t size)
else
#endif
{
FAR char **argv = tcb->group->tg_info->ta_argv + 1;
FAR char **argv = nxsched_get_stackargs(tcb) + 1;

while (*argv != NULL && n < size)
{
Expand Down
25 changes: 1 addition & 24 deletions sched/init/nx_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,21 +209,10 @@ static struct tcb_s g_idletcb[CONFIG_SMP_NCPUS];

/* This is the name of the idle task */

#if CONFIG_TASK_NAME_SIZE <= 0 || !defined(CONFIG_SMP)
# ifdef CONFIG_SMP
static const char g_idlename[] = "CPU_Idle";
# else
#if CONFIG_TASK_NAME_SIZE > 0 && !defined(CONFIG_SMP)
static const char g_idlename[] = "Idle_Task";
# endif
#endif

/* This is IDLE threads argument list. NOTE: Normally the argument
* list is created on the stack prior to starting the task. We have to
* do things little differently here for the IDLE tasks.
*/

static FAR char *g_idleargv[CONFIG_SMP_NCPUS][2];

/****************************************************************************
* Private Functions
****************************************************************************/
Expand Down Expand Up @@ -419,17 +408,6 @@ static void idle_task_initialize(void)
strlcpy(tcb->name, g_idlename, CONFIG_TASK_NAME_SIZE);
# endif

/* Configure the task name in the argument list. The IDLE task does
* not really have an argument list, but this name is still useful
* for things like the NSH PS command.
*
* In the kernel mode build, the arguments are saved on the task's
* stack and there is no support that yet.
*/

g_idleargv[i][0] = tcb->name;
#else
g_idleargv[i][0] = (FAR char *)g_idlename;
#endif /* CONFIG_TASK_NAME_SIZE */

/* Then add the idle task's TCB to the head of the current ready to
Expand Down Expand Up @@ -476,7 +454,6 @@ static void idle_group_initialize(void)

DEBUGVERIFY(
group_initialize((FAR struct task_tcb_s *)tcb, tcb->flags));
tcb->group->tg_info->ta_argv = &g_idleargv[i][0];

/* Initialize the task join */

Expand Down
5 changes: 3 additions & 2 deletions sched/task/task_fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ FAR struct task_tcb_s *nxtask_setup_fork(start_t retaddr)
FAR struct tcb_s *ptcb = this_task();
FAR struct tcb_s *parent;
FAR struct task_tcb_s *child;
FAR char **argv;
size_t stack_size;
uint8_t ttype;
int priority;
Expand Down Expand Up @@ -211,8 +212,8 @@ FAR struct task_tcb_s *nxtask_setup_fork(start_t retaddr)

/* Setup to pass parameters to the new task */

ret = nxtask_setup_arguments(child, parent->group->tg_info->ta_argv[0],
&parent->group->tg_info->ta_argv[1]);
argv = nxsched_get_stackargs(parent);
ret = nxtask_setup_arguments(child, argv[0], &argv[1]);
if (ret < OK)
{
goto errout_with_tcb;
Expand Down
7 changes: 0 additions & 7 deletions sched/task/task_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,6 @@ static int nxtask_setup_stackargs(FAR struct task_tcb_s *tcb,
FAR const char *name,
FAR char * const argv[])
{
const uint8_t ttype = tcb->cmn.flags & TCB_FLAG_TTYPE_MASK;
FAR char **stackargv;
FAR char *str;
size_t strtablen;
Expand Down Expand Up @@ -632,12 +631,6 @@ static int nxtask_setup_stackargs(FAR struct task_tcb_s *tcb,

stackargv[argc + 1] = NULL;

if (ttype != TCB_FLAG_TTYPE_KERNEL)
{
tcb->cmn.group->tg_info->ta_argc = argc;
tcb->cmn.group->tg_info->ta_argv = stackargv;
}

return OK;
}

Expand Down

0 comments on commit b949bca

Please sign in to comment.