sched: Change tcb_s to task_tcb_s for nxtask_[un]init
since these functions can just work with task not thread Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
1306cbc16e
commit
14ecb8723a
4 changed files with 22 additions and 23 deletions
|
@ -156,7 +156,7 @@ int exec_module(FAR const struct binary_s *binp)
|
||||||
|
|
||||||
/* Initialize the task */
|
/* Initialize the task */
|
||||||
|
|
||||||
ret = nxtask_init((FAR struct tcb_s *)tcb, binp->filename, binp->priority,
|
ret = nxtask_init(tcb, binp->filename, binp->priority,
|
||||||
NULL, binp->stacksize, binp->entrypt, binp->argv);
|
NULL, binp->stacksize, binp->entrypt, binp->argv);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -963,7 +963,7 @@ FAR struct socketlist *nxsched_get_sockets(void);
|
||||||
*
|
*
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
int nxtask_init(FAR struct tcb_s *tcb, const char *name, int priority,
|
int nxtask_init(FAR struct task_tcb_s *tcb, const char *name, int priority,
|
||||||
FAR void *stack, uint32_t stack_size, main_t entry,
|
FAR void *stack, uint32_t stack_size, main_t entry,
|
||||||
FAR char * const argv[]);
|
FAR char * const argv[]);
|
||||||
|
|
||||||
|
@ -988,7 +988,7 @@ int nxtask_init(FAR struct tcb_s *tcb, const char *name, int priority,
|
||||||
*
|
*
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
void nxtask_uninit(FAR struct tcb_s *tcb);
|
void nxtask_uninit(FAR struct task_tcb_s *tcb);
|
||||||
|
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Name: nxtask_activate
|
* Name: nxtask_activate
|
||||||
|
|
|
@ -72,13 +72,13 @@ static int nxthread_create(FAR const char *name, uint8_t ttype,
|
||||||
int priority, int stack_size, main_t entry,
|
int priority, int stack_size, main_t entry,
|
||||||
FAR char * const argv[])
|
FAR char * const argv[])
|
||||||
{
|
{
|
||||||
FAR struct tcb_s *tcb;
|
FAR struct task_tcb_s *tcb;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Allocate a TCB for the new task. */
|
/* Allocate a TCB for the new task. */
|
||||||
|
|
||||||
tcb = (FAR struct tcb_s *)kmm_zalloc(sizeof(struct task_tcb_s));
|
tcb = (FAR struct task_tcb_s *)kmm_zalloc(sizeof(struct task_tcb_s));
|
||||||
if (!tcb)
|
if (!tcb)
|
||||||
{
|
{
|
||||||
serr("ERROR: Failed to allocate TCB\n");
|
serr("ERROR: Failed to allocate TCB\n");
|
||||||
|
@ -87,7 +87,7 @@ static int nxthread_create(FAR const char *name, uint8_t ttype,
|
||||||
|
|
||||||
/* Setup the task type */
|
/* Setup the task type */
|
||||||
|
|
||||||
tcb->flags = ttype;
|
tcb->cmn.flags = ttype;
|
||||||
|
|
||||||
/* Initialize the task */
|
/* Initialize the task */
|
||||||
|
|
||||||
|
@ -100,11 +100,11 @@ static int nxthread_create(FAR const char *name, uint8_t ttype,
|
||||||
|
|
||||||
/* Get the assigned pid before we start the task */
|
/* Get the assigned pid before we start the task */
|
||||||
|
|
||||||
pid = tcb->pid;
|
pid = tcb->cmn.pid;
|
||||||
|
|
||||||
/* Activate the task */
|
/* Activate the task */
|
||||||
|
|
||||||
nxtask_activate(tcb);
|
nxtask_activate(&tcb->cmn);
|
||||||
|
|
||||||
return (int)pid;
|
return (int)pid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,12 +82,11 @@
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int nxtask_init(FAR struct tcb_s *tcb, const char *name, int priority,
|
int nxtask_init(FAR struct task_tcb_s *tcb, const char *name, int priority,
|
||||||
FAR void *stack, uint32_t stack_size,
|
FAR void *stack, uint32_t stack_size,
|
||||||
main_t entry, FAR char * const argv[])
|
main_t entry, FAR char * const argv[])
|
||||||
{
|
{
|
||||||
FAR struct task_tcb_s *ttcb = (FAR struct task_tcb_s *)tcb;
|
uint8_t ttype = tcb->cmn.flags & TCB_FLAG_TTYPE_MASK;
|
||||||
uint8_t ttype = tcb->flags & TCB_FLAG_TTYPE_MASK;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Only tasks and kernel threads can be initialized in this way */
|
/* Only tasks and kernel threads can be initialized in this way */
|
||||||
|
@ -98,7 +97,7 @@ int nxtask_init(FAR struct tcb_s *tcb, const char *name, int priority,
|
||||||
|
|
||||||
/* Create a new task group */
|
/* Create a new task group */
|
||||||
|
|
||||||
ret = group_allocate(ttcb, tcb->flags);
|
ret = group_allocate(tcb, tcb->cmn.flags);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -106,7 +105,7 @@ int nxtask_init(FAR struct tcb_s *tcb, const char *name, int priority,
|
||||||
|
|
||||||
/* Associate file descriptors with the new task */
|
/* Associate file descriptors with the new task */
|
||||||
|
|
||||||
ret = group_setuptaskfiles(ttcb);
|
ret = group_setuptaskfiles(tcb);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
goto errout_with_group;
|
goto errout_with_group;
|
||||||
|
@ -116,13 +115,13 @@ int nxtask_init(FAR struct tcb_s *tcb, const char *name, int priority,
|
||||||
{
|
{
|
||||||
/* Use pre-allocated stack */
|
/* Use pre-allocated stack */
|
||||||
|
|
||||||
ret = up_use_stack(tcb, stack, stack_size);
|
ret = up_use_stack(&tcb->cmn, stack, stack_size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Allocate the stack for the TCB */
|
/* Allocate the stack for the TCB */
|
||||||
|
|
||||||
ret = up_create_stack(tcb, stack_size, ttype);
|
ret = up_create_stack(&tcb->cmn, stack_size, ttype);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret < OK)
|
if (ret < OK)
|
||||||
|
@ -132,7 +131,7 @@ int nxtask_init(FAR struct tcb_s *tcb, const char *name, int priority,
|
||||||
|
|
||||||
/* Initialize the task control block */
|
/* Initialize the task control block */
|
||||||
|
|
||||||
ret = nxtask_setup_scheduler(ttcb, priority, nxtask_start,
|
ret = nxtask_setup_scheduler(tcb, priority, nxtask_start,
|
||||||
entry, ttype);
|
entry, ttype);
|
||||||
if (ret < OK)
|
if (ret < OK)
|
||||||
{
|
{
|
||||||
|
@ -141,11 +140,11 @@ int nxtask_init(FAR struct tcb_s *tcb, const char *name, int priority,
|
||||||
|
|
||||||
/* Setup to pass parameters to the new task */
|
/* Setup to pass parameters to the new task */
|
||||||
|
|
||||||
nxtask_setup_arguments(ttcb, name, argv);
|
nxtask_setup_arguments(tcb, name, argv);
|
||||||
|
|
||||||
/* Now we have enough in place that we can join the group */
|
/* Now we have enough in place that we can join the group */
|
||||||
|
|
||||||
ret = group_initialize(ttcb);
|
ret = group_initialize(tcb);
|
||||||
if (ret == OK)
|
if (ret == OK)
|
||||||
{
|
{
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -159,7 +158,7 @@ int nxtask_init(FAR struct tcb_s *tcb, const char *name, int priority,
|
||||||
|
|
||||||
errout_with_group:
|
errout_with_group:
|
||||||
|
|
||||||
if (!stack && tcb->stack_alloc_ptr)
|
if (!stack && tcb->cmn.stack_alloc_ptr)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_BUILD_KERNEL
|
#ifdef CONFIG_BUILD_KERNEL
|
||||||
/* If the exiting thread is not a kernel thread, then it has an
|
/* If the exiting thread is not a kernel thread, then it has an
|
||||||
|
@ -175,11 +174,11 @@ errout_with_group:
|
||||||
if (ttype == TCB_FLAG_TTYPE_KERNEL)
|
if (ttype == TCB_FLAG_TTYPE_KERNEL)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
up_release_stack(tcb, ttype);
|
up_release_stack(&tcb->cmn, ttype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
group_leave(tcb);
|
group_leave(&tcb->cmn);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -205,7 +204,7 @@ errout_with_group:
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void nxtask_uninit(FAR struct tcb_s *tcb)
|
void nxtask_uninit(FAR struct task_tcb_s *tcb)
|
||||||
{
|
{
|
||||||
/* The TCB was added to the inactive task list by
|
/* The TCB was added to the inactive task list by
|
||||||
* nxtask_setup_scheduler().
|
* nxtask_setup_scheduler().
|
||||||
|
@ -218,5 +217,5 @@ void nxtask_uninit(FAR struct tcb_s *tcb)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
nxsched_release_tcb((FAR struct tcb_s *)tcb,
|
nxsched_release_tcb((FAR struct tcb_s *)tcb,
|
||||||
tcb->flags & TCB_FLAG_TTYPE_MASK);
|
tcb->cmn.flags & TCB_FLAG_TTYPE_MASK);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue