sched/tls: drop ta_argv and g_idleargv
- replaces `ta_argv` with `stackargs` - drops `ta_argv` from `task_info_s` - drops `g_idleargv` and checks idle accordingly Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
This commit is contained in:
parent
8a8c1f943e
commit
3b1f4562a0
@ -122,8 +122,6 @@ struct pthread_atfork_s
|
|||||||
struct task_info_s
|
struct task_info_s
|
||||||
{
|
{
|
||||||
mutex_t ta_lock;
|
mutex_t ta_lock;
|
||||||
int ta_argc; /* Number of arguments */
|
|
||||||
FAR char **ta_argv; /* Name+start-up parameters */
|
|
||||||
#if CONFIG_TLS_TASK_NELEM > 0
|
#if CONFIG_TLS_TASK_NELEM > 0
|
||||||
uintptr_t ta_telem[CONFIG_TLS_TASK_NELEM]; /* Task local storage elements */
|
uintptr_t ta_telem[CONFIG_TLS_TASK_NELEM]; /* Task local storage elements */
|
||||||
#endif
|
#endif
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <nuttx/tls.h>
|
#include <nuttx/sched.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
@ -33,12 +33,18 @@
|
|||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: getprogname
|
* Name: getprogname
|
||||||
|
*
|
||||||
|
* Note that previous impl returns address in the stack of main thread when
|
||||||
|
* used from a pthread, that is dangerous as main thread may end earlier.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
FAR const char *getprogname(void)
|
FAR const char *getprogname(void)
|
||||||
{
|
{
|
||||||
FAR struct task_info_s *info;
|
struct stackinfo_s si;
|
||||||
|
FAR struct tls_info_s *ti = tls_get_info();
|
||||||
|
uintptr_t ret = ti ? (uintptr_t)ti + ti->tl_size : 0;
|
||||||
|
int rc = nxsched_get_stackinfo(0, &si);
|
||||||
|
|
||||||
info = task_get_info();
|
return (rc >= 0 && ret && ((uintptr_t)si.stack_base_ptr) > ret) ?
|
||||||
return info->ta_argv[0];
|
((FAR char **)ret)[0] : NULL;
|
||||||
}
|
}
|
||||||
|
@ -63,12 +63,11 @@ size_t group_argvstr(FAR struct tcb_s *tcb, FAR char *args, size_t size)
|
|||||||
FAR struct addrenv_s *oldenv;
|
FAR struct addrenv_s *oldenv;
|
||||||
#endif
|
#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';
|
*args = '\0';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -90,7 +89,7 @@ size_t group_argvstr(FAR struct tcb_s *tcb, FAR char *args, size_t size)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
FAR char **argv = tcb->group->tg_info->ta_argv + 1;
|
FAR char **argv = nxsched_get_stackargs(tcb) + 1;
|
||||||
|
|
||||||
while (*argv != NULL && n < size)
|
while (*argv != NULL && n < size)
|
||||||
{
|
{
|
||||||
|
@ -210,21 +210,10 @@ static struct tcb_s g_idletcb[CONFIG_SMP_NCPUS];
|
|||||||
|
|
||||||
/* This is the name of the idle task */
|
/* This is the name of the idle task */
|
||||||
|
|
||||||
#if CONFIG_TASK_NAME_SIZE <= 0 || !defined(CONFIG_SMP)
|
#if CONFIG_TASK_NAME_SIZE > 0 && !defined(CONFIG_SMP)
|
||||||
# ifdef CONFIG_SMP
|
|
||||||
static const char g_idlename[] = "CPU_Idle";
|
|
||||||
# else
|
|
||||||
static const char g_idlename[] = "Idle_Task";
|
static const char g_idlename[] = "Idle_Task";
|
||||||
# endif
|
|
||||||
#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
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -420,17 +409,6 @@ static void idle_task_initialize(void)
|
|||||||
strlcpy(tcb->name, g_idlename, CONFIG_TASK_NAME_SIZE);
|
strlcpy(tcb->name, g_idlename, CONFIG_TASK_NAME_SIZE);
|
||||||
# endif
|
# 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 */
|
#endif /* CONFIG_TASK_NAME_SIZE */
|
||||||
|
|
||||||
/* Then add the idle task's TCB to the head of the current ready to
|
/* Then add the idle task's TCB to the head of the current ready to
|
||||||
@ -477,7 +455,6 @@ static void idle_group_initialize(void)
|
|||||||
|
|
||||||
DEBUGVERIFY(
|
DEBUGVERIFY(
|
||||||
group_initialize((FAR struct task_tcb_s *)tcb, tcb->flags));
|
group_initialize((FAR struct task_tcb_s *)tcb, tcb->flags));
|
||||||
tcb->group->tg_info->ta_argv = &g_idleargv[i][0];
|
|
||||||
|
|
||||||
/* Initialize the task join */
|
/* Initialize the task join */
|
||||||
|
|
||||||
|
@ -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 *ptcb = this_task();
|
||||||
FAR struct tcb_s *parent;
|
FAR struct tcb_s *parent;
|
||||||
FAR struct task_tcb_s *child;
|
FAR struct task_tcb_s *child;
|
||||||
|
FAR char **argv;
|
||||||
size_t stack_size;
|
size_t stack_size;
|
||||||
uint8_t ttype;
|
uint8_t ttype;
|
||||||
int priority;
|
int priority;
|
||||||
@ -211,8 +212,8 @@ FAR struct task_tcb_s *nxtask_setup_fork(start_t retaddr)
|
|||||||
|
|
||||||
/* Setup to pass parameters to the new task */
|
/* Setup to pass parameters to the new task */
|
||||||
|
|
||||||
ret = nxtask_setup_arguments(child, parent->group->tg_info->ta_argv[0],
|
argv = nxsched_get_stackargs(parent);
|
||||||
&parent->group->tg_info->ta_argv[1]);
|
ret = nxtask_setup_arguments(child, argv[0], &argv[1]);
|
||||||
if (ret < OK)
|
if (ret < OK)
|
||||||
{
|
{
|
||||||
goto errout_with_tcb;
|
goto errout_with_tcb;
|
||||||
|
@ -528,7 +528,6 @@ static int nxtask_setup_stackargs(FAR struct task_tcb_s *tcb,
|
|||||||
FAR const char *name,
|
FAR const char *name,
|
||||||
FAR char * const argv[])
|
FAR char * const argv[])
|
||||||
{
|
{
|
||||||
uint8_t ttype = tcb->cmn.flags & TCB_FLAG_TTYPE_MASK;
|
|
||||||
FAR char **stackargv;
|
FAR char **stackargv;
|
||||||
FAR char *str;
|
FAR char *str;
|
||||||
size_t strtablen;
|
size_t strtablen;
|
||||||
@ -632,12 +631,6 @@ static int nxtask_setup_stackargs(FAR struct task_tcb_s *tcb,
|
|||||||
|
|
||||||
stackargv[argc + 1] = NULL;
|
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;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user