mirror of
https://github.com/apache/nuttx.git
synced 2025-12-15 00:41:51 +08:00
arch: _exit should't call nxsched_resume_scheduler twice in SMP mode
utilize the call inside nxtask_exit instead, also move nxsched_suspend_scheduler to nxtask_exit for symmetry Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> Change-Id: I219fc15faf0026e452b0db3906aa40b40ac677f3
This commit is contained in:
committed by
Abdelatif Guettouche
parent
c45289eb89
commit
85b859fb8d
@@ -141,10 +141,6 @@ void _exit(int status)
|
|||||||
nxsched_foreach(_up_dumponexit, NULL);
|
nxsched_foreach(_up_dumponexit, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Destroy the task at the head of the ready to run list. */
|
/* Destroy the task at the head of the ready to run list. */
|
||||||
|
|
||||||
nxtask_exit();
|
nxtask_exit();
|
||||||
@@ -165,10 +161,6 @@ void _exit(int status)
|
|||||||
group_addrenv(tcb);
|
group_addrenv(tcb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
arm_fullcontextrestore(tcb->xcp.regs);
|
arm_fullcontextrestore(tcb->xcp.regs);
|
||||||
|
|||||||
@@ -156,10 +156,6 @@ void _exit(int status)
|
|||||||
nxsched_foreach(_up_dumponexit, NULL);
|
nxsched_foreach(_up_dumponexit, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Destroy the task at the head of the ready to run list. */
|
/* Destroy the task at the head of the ready to run list. */
|
||||||
|
|
||||||
nxtask_exit();
|
nxtask_exit();
|
||||||
@@ -180,10 +176,6 @@ void _exit(int status)
|
|||||||
group_addrenv(tcb);
|
group_addrenv(tcb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
up_fullcontextrestore(tcb->xcp.regs);
|
up_fullcontextrestore(tcb->xcp.regs);
|
||||||
|
|||||||
@@ -140,10 +140,6 @@ void _exit(int status)
|
|||||||
nxsched_foreach(_up_dumponexit, NULL);
|
nxsched_foreach(_up_dumponexit, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Destroy the task at the head of the ready to run list. */
|
/* Destroy the task at the head of the ready to run list. */
|
||||||
|
|
||||||
nxtask_exit();
|
nxtask_exit();
|
||||||
@@ -164,10 +160,6 @@ void _exit(int status)
|
|||||||
group_addrenv(tcb);
|
group_addrenv(tcb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
up_fullcontextrestore(tcb->xcp.regs);
|
up_fullcontextrestore(tcb->xcp.regs);
|
||||||
|
|||||||
@@ -158,10 +158,6 @@ void _exit(int status)
|
|||||||
nxsched_foreach(_up_dumponexit, NULL);
|
nxsched_foreach(_up_dumponexit, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Destroy the task at the head of the ready to run list. */
|
/* Destroy the task at the head of the ready to run list. */
|
||||||
|
|
||||||
nxtask_exit();
|
nxtask_exit();
|
||||||
@@ -182,10 +178,6 @@ void _exit(int status)
|
|||||||
group_addrenv(tcb);
|
group_addrenv(tcb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
up_fullcontextrestore(tcb->xcp.regs);
|
up_fullcontextrestore(tcb->xcp.regs);
|
||||||
|
|||||||
@@ -151,10 +151,6 @@ void _exit(int status)
|
|||||||
nxsched_foreach(_up_dumponexit, NULL);
|
nxsched_foreach(_up_dumponexit, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Destroy the task at the head of the ready to run list. */
|
/* Destroy the task at the head of the ready to run list. */
|
||||||
|
|
||||||
nxtask_exit();
|
nxtask_exit();
|
||||||
@@ -175,10 +171,6 @@ void _exit(int status)
|
|||||||
group_addrenv(tcb);
|
group_addrenv(tcb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
up_fullcontextrestore(tcb->xcp.regs);
|
up_fullcontextrestore(tcb->xcp.regs);
|
||||||
|
|||||||
@@ -149,10 +149,6 @@ void _exit(int status)
|
|||||||
nxsched_foreach(_up_dumponexit, NULL);
|
nxsched_foreach(_up_dumponexit, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Destroy the task at the head of the ready to run list. */
|
/* Destroy the task at the head of the ready to run list. */
|
||||||
|
|
||||||
nxtask_exit();
|
nxtask_exit();
|
||||||
@@ -173,10 +169,6 @@ void _exit(int status)
|
|||||||
group_addrenv(tcb);
|
group_addrenv(tcb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
up_fullcontextrestore(tcb->xcp.regs);
|
up_fullcontextrestore(tcb->xcp.regs);
|
||||||
|
|||||||
@@ -156,10 +156,6 @@ void _exit(int status)
|
|||||||
nxsched_foreach(_up_dumponexit, NULL);
|
nxsched_foreach(_up_dumponexit, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Destroy the task at the head of the ready to run list. */
|
/* Destroy the task at the head of the ready to run list. */
|
||||||
|
|
||||||
nxtask_exit();
|
nxtask_exit();
|
||||||
@@ -180,10 +176,6 @@ void _exit(int status)
|
|||||||
group_addrenv(tcb);
|
group_addrenv(tcb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
up_fullcontextrestore(tcb->xcp.regs);
|
up_fullcontextrestore(tcb->xcp.regs);
|
||||||
|
|||||||
@@ -140,10 +140,6 @@ void _exit(int status)
|
|||||||
nxsched_foreach(_up_dumponexit, NULL);
|
nxsched_foreach(_up_dumponexit, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Destroy the task at the head of the ready to run list. */
|
/* Destroy the task at the head of the ready to run list. */
|
||||||
|
|
||||||
nxtask_exit();
|
nxtask_exit();
|
||||||
@@ -164,10 +160,6 @@ void _exit(int status)
|
|||||||
group_addrenv(tcb);
|
group_addrenv(tcb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
up_fullcontextrestore(tcb->xcp.regs);
|
up_fullcontextrestore(tcb->xcp.regs);
|
||||||
|
|||||||
@@ -158,10 +158,6 @@ void _exit(int status)
|
|||||||
nxsched_foreach(_up_dumponexit, NULL);
|
nxsched_foreach(_up_dumponexit, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Destroy the task at the head of the ready to run list. */
|
/* Destroy the task at the head of the ready to run list. */
|
||||||
|
|
||||||
nxtask_exit();
|
nxtask_exit();
|
||||||
@@ -182,10 +178,6 @@ void _exit(int status)
|
|||||||
group_addrenv(tcb);
|
group_addrenv(tcb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
up_fullcontextrestore(tcb->xcp.regs);
|
up_fullcontextrestore(tcb->xcp.regs);
|
||||||
|
|||||||
@@ -69,10 +69,6 @@ void _exit(int status)
|
|||||||
|
|
||||||
sinfo("TCB=%p exiting\n", tcb);
|
sinfo("TCB=%p exiting\n", tcb);
|
||||||
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Destroy the task at the head of the ready to run list. */
|
/* Destroy the task at the head of the ready to run list. */
|
||||||
|
|
||||||
nxtask_exit();
|
nxtask_exit();
|
||||||
@@ -84,10 +80,6 @@ void _exit(int status)
|
|||||||
tcb = this_task();
|
tcb = this_task();
|
||||||
sinfo("New Active Task TCB=%p\n", tcb);
|
sinfo("New Active Task TCB=%p\n", tcb);
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* The way that we handle signals in the simulation is kind of
|
/* The way that we handle signals in the simulation is kind of
|
||||||
* a kludge. This would be unsafe in a truly multi-threaded, interrupt
|
* a kludge. This would be unsafe in a truly multi-threaded, interrupt
|
||||||
* driven environment.
|
* driven environment.
|
||||||
|
|||||||
@@ -140,10 +140,6 @@ void _exit(int status)
|
|||||||
nxsched_foreach(_up_dumponexit, NULL);
|
nxsched_foreach(_up_dumponexit, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Destroy the task at the head of the ready to run list. */
|
/* Destroy the task at the head of the ready to run list. */
|
||||||
|
|
||||||
nxtask_exit();
|
nxtask_exit();
|
||||||
@@ -164,10 +160,6 @@ void _exit(int status)
|
|||||||
group_addrenv(tcb);
|
group_addrenv(tcb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
up_fullcontextrestore(tcb->xcp.regs);
|
up_fullcontextrestore(tcb->xcp.regs);
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ void _exit(int status)
|
|||||||
* The IRQ state will be restored when the next task is started.
|
* The IRQ state will be restored when the next task is started.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(void)enter_critical_section();
|
enter_critical_section();
|
||||||
|
|
||||||
sinfo("TCB=%p exiting\n", this_task());
|
sinfo("TCB=%p exiting\n", this_task());
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ void _exit(int status)
|
|||||||
|
|
||||||
/* Destroy the task at the head of the ready to run list. */
|
/* Destroy the task at the head of the ready to run list. */
|
||||||
|
|
||||||
(void)nxtask_exit();
|
nxtask_exit();
|
||||||
|
|
||||||
/* Now, perform the context switch to the new ready-to-run task at the
|
/* Now, perform the context switch to the new ready-to-run task at the
|
||||||
* head of the list.
|
* head of the list.
|
||||||
@@ -165,11 +165,10 @@ void _exit(int status)
|
|||||||
* the ready-to-run list.
|
* the ready-to-run list.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(void)group_addrenv(tcb);
|
group_addrenv(tcb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
up_fullcontextrestore(tcb->xcp.regs);
|
up_fullcontextrestore(tcb->xcp.regs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -157,10 +157,6 @@ void _exit(int status)
|
|||||||
nxsched_foreach(_xtensa_dumponexit, NULL);
|
nxsched_foreach(_xtensa_dumponexit, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(tcb);
|
|
||||||
|
|
||||||
#if XCHAL_CP_NUM > 0
|
#if XCHAL_CP_NUM > 0
|
||||||
/* Disable co-processor support for the task that is exit-ing. */
|
/* Disable co-processor support for the task that is exit-ing. */
|
||||||
|
|
||||||
@@ -193,10 +189,6 @@ void _exit(int status)
|
|||||||
group_addrenv(tcb);
|
group_addrenv(tcb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
xtensa_context_restore(tcb->xcp.regs);
|
xtensa_context_restore(tcb->xcp.regs);
|
||||||
|
|||||||
@@ -140,10 +140,6 @@ void _exit(int status)
|
|||||||
nxsched_foreach(_z16_dumponexit, NULL);
|
nxsched_foreach(_z16_dumponexit, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Destroy the task at the head of the ready to run list. */
|
/* Destroy the task at the head of the ready to run list. */
|
||||||
|
|
||||||
nxtask_exit();
|
nxtask_exit();
|
||||||
@@ -155,10 +151,6 @@ void _exit(int status)
|
|||||||
tcb = this_task();
|
tcb = this_task();
|
||||||
sinfo("New Active Task TCB=%p\n", tcb);
|
sinfo("New Active Task TCB=%p\n", tcb);
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
RESTORE_USERCONTEXT(tcb);
|
RESTORE_USERCONTEXT(tcb);
|
||||||
|
|||||||
@@ -142,10 +142,6 @@ void _exit(int status)
|
|||||||
nxsched_foreach(_up_dumponexit, NULL);
|
nxsched_foreach(_up_dumponexit, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Destroy the task at the head of the ready to run list. */
|
/* Destroy the task at the head of the ready to run list. */
|
||||||
|
|
||||||
nxtask_exit();
|
nxtask_exit();
|
||||||
@@ -167,10 +163,6 @@ void _exit(int status)
|
|||||||
group_addrenv(tcb);
|
group_addrenv(tcb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
RESTORE_USERCONTEXT(tcb);
|
RESTORE_USERCONTEXT(tcb);
|
||||||
|
|||||||
@@ -84,6 +84,10 @@ int nxtask_exit(void)
|
|||||||
dtcb = this_task();
|
dtcb = this_task();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
nxsched_suspend_scheduler(dtcb);
|
||||||
|
|
||||||
/* Remove the TCB of the current task from the ready-to-run list. A
|
/* Remove the TCB of the current task from the ready-to-run list. A
|
||||||
* context switch will definitely be necessary -- that must be done
|
* context switch will definitely be necessary -- that must be done
|
||||||
* by the architecture-specific logic.
|
* by the architecture-specific logic.
|
||||||
@@ -102,13 +106,11 @@ int nxtask_exit(void)
|
|||||||
rtcb = this_task();
|
rtcb = this_task();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
/* Because clearing the global IRQ control in nxsched_remove_readytorun()
|
/* Because clearing the global IRQ control in nxsched_remove_readytorun()
|
||||||
* was moved to nxsched_resume_scheduler(). So call the API here.
|
* was moved to nxsched_resume_scheduler(). So call the API here.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
nxsched_resume_scheduler(rtcb);
|
nxsched_resume_scheduler(rtcb);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* We are now in a bad state -- the head of the ready to run task list
|
/* We are now in a bad state -- the head of the ready to run task list
|
||||||
* does not correspond to the thread that is running. Disabling pre-
|
* does not correspond to the thread that is running. Disabling pre-
|
||||||
|
|||||||
Reference in New Issue
Block a user