mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
sched: Call up_[use|create]_stack after nxtask_setup_scheduler
to ensure the basic info(e.g. pid) setup correctly before call arch API Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> Change-Id: I851cb0fdf22f45844938dafc5981b3f576100dba
This commit is contained in:
committed by
Masayuki Ishikawa
parent
2b5be56bd0
commit
6eba1ad90a
@@ -289,27 +289,6 @@ int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr,
|
|||||||
pjoin->detached = true;
|
pjoin->detached = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attr->stackaddr)
|
|
||||||
{
|
|
||||||
/* Use pre-allocated stack */
|
|
||||||
|
|
||||||
ret = up_use_stack((FAR struct tcb_s *)ptcb, attr->stackaddr,
|
|
||||||
attr->stacksize);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Allocate the stack for the TCB */
|
|
||||||
|
|
||||||
ret = up_create_stack((FAR struct tcb_s *)ptcb, attr->stacksize,
|
|
||||||
TCB_FLAG_TTYPE_PTHREAD);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret != OK)
|
|
||||||
{
|
|
||||||
errcode = ENOMEM;
|
|
||||||
goto errout_with_join;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Should we use the priority and scheduler specified in the pthread
|
/* Should we use the priority and scheduler specified in the pthread
|
||||||
* attributes? Or should we use the current thread's priority and
|
* attributes? Or should we use the current thread's priority and
|
||||||
* scheduler?
|
* scheduler?
|
||||||
@@ -431,6 +410,27 @@ int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (attr->stackaddr)
|
||||||
|
{
|
||||||
|
/* Use pre-allocated stack */
|
||||||
|
|
||||||
|
ret = up_use_stack((FAR struct tcb_s *)ptcb, attr->stackaddr,
|
||||||
|
attr->stacksize);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Allocate the stack for the TCB */
|
||||||
|
|
||||||
|
ret = up_create_stack((FAR struct tcb_s *)ptcb, attr->stacksize,
|
||||||
|
TCB_FLAG_TTYPE_PTHREAD);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret != OK)
|
||||||
|
{
|
||||||
|
errcode = ENOMEM;
|
||||||
|
goto errout_with_join;
|
||||||
|
}
|
||||||
|
|
||||||
/* Configure the TCB for a pthread receiving on parameter
|
/* Configure the TCB for a pthread receiving on parameter
|
||||||
* passed by value
|
* passed by value
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -108,6 +108,15 @@ int nxtask_init(FAR struct task_tcb_s *tcb, const char *name, int priority,
|
|||||||
goto errout_with_group;
|
goto errout_with_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Initialize the task control block */
|
||||||
|
|
||||||
|
ret = nxtask_setup_scheduler(tcb, priority, nxtask_start,
|
||||||
|
entry, ttype);
|
||||||
|
if (ret < OK)
|
||||||
|
{
|
||||||
|
goto errout_with_group;
|
||||||
|
}
|
||||||
|
|
||||||
if (stack)
|
if (stack)
|
||||||
{
|
{
|
||||||
/* Use pre-allocated stack */
|
/* Use pre-allocated stack */
|
||||||
@@ -126,15 +135,6 @@ int nxtask_init(FAR struct task_tcb_s *tcb, const char *name, int priority,
|
|||||||
goto errout_with_group;
|
goto errout_with_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the task control block */
|
|
||||||
|
|
||||||
ret = nxtask_setup_scheduler(tcb, priority, nxtask_start,
|
|
||||||
entry, ttype);
|
|
||||||
if (ret < OK)
|
|
||||||
{
|
|
||||||
goto errout_with_group;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Setup to pass parameters to the new task */
|
/* Setup to pass parameters to the new task */
|
||||||
|
|
||||||
nxtask_setup_arguments(tcb, name, argv);
|
nxtask_setup_arguments(tcb, name, argv);
|
||||||
|
|||||||
Reference in New Issue
Block a user