sched: Change the return type of nxtask_activate to void
to simplify the error handling logic Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> Change-Id: I00fedd4d69620a7cc7b9f9e8bf4ba7f7989dc2b2
This commit is contained in:
parent
b4bd9427f7
commit
a69678810d
@ -198,7 +198,7 @@ int exec_module(FAR const struct binary_s *binp)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_SHM)
|
||||
#ifdef CONFIG_MM_SHM
|
||||
/* Initialize the shared memory virtual page allocator */
|
||||
|
||||
ret = shm_group_initialize(tcb->cmn.group);
|
||||
@ -254,12 +254,7 @@ int exec_module(FAR const struct binary_s *binp)
|
||||
|
||||
/* Then activate the task at the provided priority */
|
||||
|
||||
ret = nxtask_activate((FAR struct tcb_s *)tcb);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("nxtask_activate() failed: %d\n", ret);
|
||||
goto errout_with_tcbinit;
|
||||
}
|
||||
nxtask_activate((FAR struct tcb_s *)tcb);
|
||||
|
||||
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
|
||||
/* Restore the address environment of the caller */
|
||||
@ -274,11 +269,13 @@ int exec_module(FAR const struct binary_s *binp)
|
||||
|
||||
return (int)pid;
|
||||
|
||||
#if defined(CONFIG_ARCH_ADDRENV) || defined(CONFIG_MM_SHM)
|
||||
errout_with_tcbinit:
|
||||
tcb->cmn.stack_alloc_ptr = NULL;
|
||||
nxsched_release_tcb(&tcb->cmn, TCB_FLAG_TTYPE_TASK);
|
||||
kumm_free(stack);
|
||||
return ret;
|
||||
#endif
|
||||
|
||||
errout_with_addrenv:
|
||||
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
|
||||
|
@ -989,11 +989,11 @@ void nxtask_uninit(FAR struct tcb_s *tcb);
|
||||
* argument).
|
||||
*
|
||||
* Returned Value:
|
||||
* Always returns OK
|
||||
* None
|
||||
*
|
||||
********************************************************************************/
|
||||
|
||||
int nxtask_activate(FAR struct tcb_s *tcb);
|
||||
void nxtask_activate(FAR struct tcb_s *tcb);
|
||||
|
||||
/********************************************************************************
|
||||
* Name: nxtask_starthook
|
||||
|
@ -553,11 +553,8 @@ int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr,
|
||||
sched_lock();
|
||||
if (ret == OK)
|
||||
{
|
||||
ret = nxtask_activate((FAR struct tcb_s *)ptcb);
|
||||
}
|
||||
nxtask_activate((FAR struct tcb_s *)ptcb);
|
||||
|
||||
if (ret == OK)
|
||||
{
|
||||
/* Wait for the task to actually get running and to register
|
||||
* its join structure.
|
||||
*/
|
||||
|
@ -49,11 +49,11 @@
|
||||
* argument).
|
||||
*
|
||||
* Returned Value:
|
||||
* Always returns OK
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nxtask_activate(FAR struct tcb_s *tcb)
|
||||
void nxtask_activate(FAR struct tcb_s *tcb)
|
||||
{
|
||||
irqstate_t flags = enter_critical_section();
|
||||
|
||||
@ -79,5 +79,4 @@ int nxtask_activate(FAR struct tcb_s *tcb)
|
||||
|
||||
up_unblock_task(tcb);
|
||||
leave_critical_section(flags);
|
||||
return OK;
|
||||
}
|
||||
|
@ -145,12 +145,7 @@ static int nxthread_create(FAR const char *name, uint8_t ttype,
|
||||
|
||||
/* Activate the task */
|
||||
|
||||
ret = nxtask_activate((FAR struct tcb_s *)tcb);
|
||||
if (ret < OK)
|
||||
{
|
||||
goto errout_with_active;
|
||||
}
|
||||
|
||||
nxtask_activate((FAR struct tcb_s *)tcb);
|
||||
return pid;
|
||||
|
||||
errout_with_active:
|
||||
|
@ -73,7 +73,6 @@ int task_restart(pid_t pid)
|
||||
#ifdef CONFIG_SMP
|
||||
int cpu;
|
||||
#endif
|
||||
int ret;
|
||||
|
||||
/* Check if the task to restart is the calling task */
|
||||
|
||||
@ -188,7 +187,7 @@ int task_restart(pid_t pid)
|
||||
|
||||
if (cpu >= 0)
|
||||
{
|
||||
ret = up_cpu_resume(cpu);
|
||||
int ret = up_cpu_resume(cpu);
|
||||
if (ret < 0)
|
||||
{
|
||||
errcode = -ret;
|
||||
@ -201,14 +200,7 @@ int task_restart(pid_t pid)
|
||||
|
||||
/* Activate the task. */
|
||||
|
||||
ret = nxtask_activate((FAR struct tcb_s *)tcb);
|
||||
if (ret != OK)
|
||||
{
|
||||
nxtask_terminate(pid, true);
|
||||
errcode = -ret;
|
||||
goto errout_with_lock;
|
||||
}
|
||||
|
||||
nxtask_activate((FAR struct tcb_s *)tcb);
|
||||
return OK;
|
||||
|
||||
errout_with_lock:
|
||||
|
@ -434,13 +434,7 @@ pid_t nxtask_start_vfork(FAR struct task_tcb_s *child)
|
||||
|
||||
/* Activate the task */
|
||||
|
||||
ret = nxtask_activate((FAR struct tcb_s *)child);
|
||||
if (ret < OK)
|
||||
{
|
||||
nxtask_abort_vfork(child, -ret);
|
||||
sched_unlock();
|
||||
return ERROR;
|
||||
}
|
||||
nxtask_activate((FAR struct tcb_s *)child);
|
||||
|
||||
/* The child task has not yet ran because pre-emption is disabled.
|
||||
* The child task has the same priority as the parent task, so that
|
||||
|
Loading…
Reference in New Issue
Block a user