This is an automated email from the ASF dual-hosted git repository. gnutt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push: new 14ecb87 sched: Change tcb_s to task_tcb_s for nxtask_[un]init 14ecb87 is described below commit 14ecb8723acfd243fead5cfa2f64a706864d7d3a Author: Xiang Xiao <xiaoxi...@xiaomi.com> AuthorDate: Mon Jun 29 15:52:16 2020 +0800 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 <xiaoxi...@xiaomi.com> --- binfmt/binfmt_execmodule.c | 2 +- include/nuttx/sched.h | 4 ++-- sched/task/task_create.c | 10 +++++----- sched/task/task_init.c | 29 ++++++++++++++--------------- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/binfmt/binfmt_execmodule.c b/binfmt/binfmt_execmodule.c index 57a6fd0..3acfeec 100644 --- a/binfmt/binfmt_execmodule.c +++ b/binfmt/binfmt_execmodule.c @@ -156,7 +156,7 @@ int exec_module(FAR const struct binary_s *binp) /* 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); if (ret < 0) { diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h index ec545cc..b183771 100644 --- a/include/nuttx/sched.h +++ b/include/nuttx/sched.h @@ -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 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 diff --git a/sched/task/task_create.c b/sched/task/task_create.c index ea640f0..9915c5d 100644 --- a/sched/task/task_create.c +++ b/sched/task/task_create.c @@ -72,13 +72,13 @@ static int nxthread_create(FAR const char *name, uint8_t ttype, int priority, int stack_size, main_t entry, FAR char * const argv[]) { - FAR struct tcb_s *tcb; + FAR struct task_tcb_s *tcb; pid_t pid; int ret; /* 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) { 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 */ - tcb->flags = ttype; + tcb->cmn.flags = ttype; /* 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 */ - pid = tcb->pid; + pid = tcb->cmn.pid; /* Activate the task */ - nxtask_activate(tcb); + nxtask_activate(&tcb->cmn); return (int)pid; } diff --git a/sched/task/task_init.c b/sched/task/task_init.c index 3f1a27a..15ae7ec 100644 --- a/sched/task/task_init.c +++ b/sched/task/task_init.c @@ -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, main_t entry, FAR char * const argv[]) { - FAR struct task_tcb_s *ttcb = (FAR struct task_tcb_s *)tcb; - uint8_t ttype = tcb->flags & TCB_FLAG_TTYPE_MASK; + uint8_t ttype = tcb->cmn.flags & TCB_FLAG_TTYPE_MASK; int ret; /* 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 */ - ret = group_allocate(ttcb, tcb->flags); + ret = group_allocate(tcb, tcb->cmn.flags); if (ret < 0) { 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 */ - ret = group_setuptaskfiles(ttcb); + ret = group_setuptaskfiles(tcb); if (ret < 0) { 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 */ - ret = up_use_stack(tcb, stack, stack_size); + ret = up_use_stack(&tcb->cmn, stack, stack_size); } else { /* 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) @@ -132,7 +131,7 @@ int nxtask_init(FAR struct tcb_s *tcb, const char *name, int priority, /* Initialize the task control block */ - ret = nxtask_setup_scheduler(ttcb, priority, nxtask_start, + ret = nxtask_setup_scheduler(tcb, priority, nxtask_start, entry, ttype); 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 */ - nxtask_setup_arguments(ttcb, name, argv); + nxtask_setup_arguments(tcb, name, argv); /* Now we have enough in place that we can join the group */ - ret = group_initialize(ttcb); + ret = group_initialize(tcb); if (ret == OK) { return ret; @@ -159,7 +158,7 @@ int nxtask_init(FAR struct tcb_s *tcb, const char *name, int priority, errout_with_group: - if (!stack && tcb->stack_alloc_ptr) + if (!stack && tcb->cmn.stack_alloc_ptr) { #ifdef CONFIG_BUILD_KERNEL /* 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) #endif { - up_release_stack(tcb, ttype); + up_release_stack(&tcb->cmn, ttype); } } - group_leave(tcb); + group_leave(&tcb->cmn); 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 * nxtask_setup_scheduler(). @@ -218,5 +217,5 @@ void nxtask_uninit(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); }