SMP: Reorder some logic related to task exit() and restart() for logic of SMP.
This commit is contained in:
parent
2534791a2e
commit
f0671bae2f
2
arch
2
arch
@ -1 +1 @@
|
||||
Subproject commit 0401b8ce61ca07c7680763dcfa4b40ad42d8dc4d
|
||||
Subproject commit f0253cc8a66234efcffeac1ae44ff2d9c329766c
|
@ -127,22 +127,7 @@ int task_exit(void)
|
||||
ret = task_terminate(dtcb->pid, true);
|
||||
rtcb->task_state = TSTATE_TASK_RUNNING;
|
||||
|
||||
/* If there are any pending tasks, then add them to the ready-to-run
|
||||
* task list now
|
||||
*/
|
||||
|
||||
if (g_pendingtasks.head != NULL)
|
||||
{
|
||||
(void)sched_mergepending();
|
||||
}
|
||||
|
||||
/* We can't use sched_unlock() to decrement the lock count because the
|
||||
* sched_mergepending() call above might have changed the task at the
|
||||
* head of the ready-to-run list. Furthermore, we should not need to
|
||||
* perform the unlock action anyway because we know that the pending
|
||||
* task list is empty. So all we really need to do is to decrement
|
||||
* the lockcount on rctb.
|
||||
*/
|
||||
/* Decrement the lockcount on rctb. */
|
||||
|
||||
rtcb->lockcount--;
|
||||
|
||||
@ -156,5 +141,14 @@ int task_exit(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If there are any pending tasks, then add them to the ready-to-run
|
||||
* task list now
|
||||
*/
|
||||
|
||||
if (g_pendingtasks.head != NULL)
|
||||
{
|
||||
(void)sched_mergepending();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -83,10 +83,11 @@ int task_restart(pid_t pid)
|
||||
FAR struct task_tcb_s *tcb;
|
||||
FAR dq_queue_t *tasklist;
|
||||
irqstate_t flags;
|
||||
int err;
|
||||
int status;
|
||||
|
||||
/* Make sure this task does not become ready-to-run while
|
||||
* we are futzing with its TCB
|
||||
/* Make sure this task does not become ready-to-run while we are futzing
|
||||
* with its TCB
|
||||
*/
|
||||
|
||||
sched_lock();
|
||||
@ -98,29 +99,10 @@ int task_restart(pid_t pid)
|
||||
{
|
||||
/* Not implemented */
|
||||
|
||||
set_errno(ENOSYS);
|
||||
return ERROR;
|
||||
err = ENOSYS;
|
||||
goto errout_with_lock;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
/* There is currently no capability to restart a task that is actively
|
||||
* running on another CPU either. This is not the calling cast so if it
|
||||
* is running, then it could only be running a a different CPU.
|
||||
*
|
||||
* Also, will need some interlocks to assure that no tasks are rescheduled
|
||||
* on any other CPU while we do this.
|
||||
*/
|
||||
|
||||
#warning Missing SMP logic
|
||||
if (rtcb->task_state == TSTATE_TASK_RUNNING)
|
||||
{
|
||||
/* Not implemented */
|
||||
|
||||
set_errno(ENOSYS);
|
||||
return ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* We are restarting some other task than ourselves */
|
||||
/* Find for the TCB associated with matching pid */
|
||||
|
||||
@ -133,10 +115,29 @@ int task_restart(pid_t pid)
|
||||
{
|
||||
/* There is no TCB with this pid or, if there is, it is not a task. */
|
||||
|
||||
set_errno(ESRCH);
|
||||
return ERROR;
|
||||
err = ESRCH;
|
||||
goto errout_with_lock;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
/* There is currently no capability to restart a task that is actively
|
||||
* running on another CPU. This is not the calling task so if it is
|
||||
* running, then it could only be running a a different CPU.
|
||||
*
|
||||
* Also, we will need some interlocks to assure that no tasks are
|
||||
* rescheduled on any other CPU while we do this.
|
||||
*/
|
||||
|
||||
#warning Missing SMP logic
|
||||
if (tcb->cmn.task_state == TSTATE_TASK_RUNNING)
|
||||
{
|
||||
/* Not implemented */
|
||||
|
||||
err = ENOSYS;
|
||||
goto errout_with_lock;
|
||||
}
|
||||
#endif /* CONFIG_SMP */
|
||||
|
||||
/* Try to recover from any bad states */
|
||||
|
||||
task_recover((FAR struct tcb_s *)tcb);
|
||||
@ -196,10 +197,15 @@ int task_restart(pid_t pid)
|
||||
if (status != OK)
|
||||
{
|
||||
(void)task_delete(pid);
|
||||
set_errno(-status);
|
||||
return ERROR;
|
||||
err = -status;
|
||||
goto errout_with_lock;
|
||||
}
|
||||
|
||||
sched_unlock();
|
||||
return OK;
|
||||
|
||||
errout_with_lock:
|
||||
set_errno(err);
|
||||
sched_unlock();
|
||||
return ERROR;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user