You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ag...@apache.org on 2020/06/04 21:20:55 UTC
[incubator-nuttx] 01/03: arch: _exit should't call
nxsched_resume_scheduler twice in SMP mode
This is an automated email from the ASF dual-hosted git repository.
aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 85b859fb8d65be12e6ea5419b1ae53046bf4b93c
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Thu Jun 4 13:59:09 2020 +0800
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 <xi...@xiaomi.com>
Change-Id: I219fc15faf0026e452b0db3906aa40b40ac677f3
---
arch/arm/src/common/arm_exit.c | 8 --------
arch/avr/src/common/up_exit.c | 8 --------
arch/hc/src/common/up_exit.c | 8 --------
arch/mips/src/common/mips_exit.c | 8 --------
arch/misoc/src/lm32/lm32_exit.c | 8 --------
arch/misoc/src/minerva/minerva_exit.c | 8 --------
arch/or1k/src/common/up_exit.c | 8 --------
arch/renesas/src/common/up_exit.c | 8 --------
arch/risc-v/src/common/riscv_exit.c | 8 --------
arch/sim/src/sim/up_exit.c | 8 --------
arch/x86/src/common/up_exit.c | 8 --------
arch/x86_64/src/common/up_exit.c | 7 +++----
arch/xtensa/src/common/xtensa_exit.c | 8 --------
arch/z16/src/common/z16_exit.c | 8 --------
arch/z80/src/common/z80_exit.c | 8 --------
sched/task/task_exit.c | 6 ++++--
16 files changed, 7 insertions(+), 118 deletions(-)
diff --git a/arch/arm/src/common/arm_exit.c b/arch/arm/src/common/arm_exit.c
index 261f2aa..1941387 100644
--- a/arch/arm/src/common/arm_exit.c
+++ b/arch/arm/src/common/arm_exit.c
@@ -141,10 +141,6 @@ void _exit(int status)
nxsched_foreach(_up_dumponexit, NULL);
#endif
- /* Update scheduler parameters */
-
- nxsched_suspend_scheduler(tcb);
-
/* Destroy the task at the head of the ready to run list. */
nxtask_exit();
@@ -165,10 +161,6 @@ void _exit(int status)
group_addrenv(tcb);
#endif
- /* Reset scheduler parameters */
-
- nxsched_resume_scheduler(tcb);
-
/* Then switch contexts */
arm_fullcontextrestore(tcb->xcp.regs);
diff --git a/arch/avr/src/common/up_exit.c b/arch/avr/src/common/up_exit.c
index ef91c8b..051b7fd 100644
--- a/arch/avr/src/common/up_exit.c
+++ b/arch/avr/src/common/up_exit.c
@@ -156,10 +156,6 @@ void _exit(int status)
nxsched_foreach(_up_dumponexit, NULL);
#endif
- /* Update scheduler parameters */
-
- nxsched_suspend_scheduler(tcb);
-
/* Destroy the task at the head of the ready to run list. */
nxtask_exit();
@@ -180,10 +176,6 @@ void _exit(int status)
group_addrenv(tcb);
#endif
- /* Reset scheduler parameters */
-
- nxsched_resume_scheduler(tcb);
-
/* Then switch contexts */
up_fullcontextrestore(tcb->xcp.regs);
diff --git a/arch/hc/src/common/up_exit.c b/arch/hc/src/common/up_exit.c
index 6795b5b..cb2be42 100644
--- a/arch/hc/src/common/up_exit.c
+++ b/arch/hc/src/common/up_exit.c
@@ -140,10 +140,6 @@ void _exit(int status)
nxsched_foreach(_up_dumponexit, NULL);
#endif
- /* Update scheduler parameters */
-
- nxsched_suspend_scheduler(tcb);
-
/* Destroy the task at the head of the ready to run list. */
nxtask_exit();
@@ -164,10 +160,6 @@ void _exit(int status)
group_addrenv(tcb);
#endif
- /* Reset scheduler parameters */
-
- nxsched_resume_scheduler(tcb);
-
/* Then switch contexts */
up_fullcontextrestore(tcb->xcp.regs);
diff --git a/arch/mips/src/common/mips_exit.c b/arch/mips/src/common/mips_exit.c
index ec5c0e1..fd85164 100644
--- a/arch/mips/src/common/mips_exit.c
+++ b/arch/mips/src/common/mips_exit.c
@@ -158,10 +158,6 @@ void _exit(int status)
nxsched_foreach(_up_dumponexit, NULL);
#endif
- /* Update scheduler parameters */
-
- nxsched_suspend_scheduler(tcb);
-
/* Destroy the task at the head of the ready to run list. */
nxtask_exit();
@@ -182,10 +178,6 @@ void _exit(int status)
group_addrenv(tcb);
#endif
- /* Reset scheduler parameters */
-
- nxsched_resume_scheduler(tcb);
-
/* Then switch contexts */
up_fullcontextrestore(tcb->xcp.regs);
diff --git a/arch/misoc/src/lm32/lm32_exit.c b/arch/misoc/src/lm32/lm32_exit.c
index 93a9e9f..8c6f7d8 100644
--- a/arch/misoc/src/lm32/lm32_exit.c
+++ b/arch/misoc/src/lm32/lm32_exit.c
@@ -151,10 +151,6 @@ void _exit(int status)
nxsched_foreach(_up_dumponexit, NULL);
#endif
- /* Update scheduler parameters */
-
- nxsched_suspend_scheduler(tcb);
-
/* Destroy the task at the head of the ready to run list. */
nxtask_exit();
@@ -175,10 +171,6 @@ void _exit(int status)
group_addrenv(tcb);
#endif
- /* Reset scheduler parameters */
-
- nxsched_resume_scheduler(tcb);
-
/* Then switch contexts */
up_fullcontextrestore(tcb->xcp.regs);
diff --git a/arch/misoc/src/minerva/minerva_exit.c b/arch/misoc/src/minerva/minerva_exit.c
index 9ab3840..61e4499 100644
--- a/arch/misoc/src/minerva/minerva_exit.c
+++ b/arch/misoc/src/minerva/minerva_exit.c
@@ -149,10 +149,6 @@ void _exit(int status)
nxsched_foreach(_up_dumponexit, NULL);
#endif
- /* Update scheduler parameters */
-
- nxsched_suspend_scheduler(tcb);
-
/* Destroy the task at the head of the ready to run list. */
nxtask_exit();
@@ -173,10 +169,6 @@ void _exit(int status)
group_addrenv(tcb);
#endif
- /* Reset scheduler parameters */
-
- nxsched_resume_scheduler(tcb);
-
/* Then switch contexts */
up_fullcontextrestore(tcb->xcp.regs);
diff --git a/arch/or1k/src/common/up_exit.c b/arch/or1k/src/common/up_exit.c
index fd2cd7a..f37a940 100644
--- a/arch/or1k/src/common/up_exit.c
+++ b/arch/or1k/src/common/up_exit.c
@@ -156,10 +156,6 @@ void _exit(int status)
nxsched_foreach(_up_dumponexit, NULL);
#endif
- /* Update scheduler parameters */
-
- nxsched_suspend_scheduler(tcb);
-
/* Destroy the task at the head of the ready to run list. */
nxtask_exit();
@@ -180,10 +176,6 @@ void _exit(int status)
group_addrenv(tcb);
#endif
- /* Reset scheduler parameters */
-
- nxsched_resume_scheduler(tcb);
-
/* Then switch contexts */
up_fullcontextrestore(tcb->xcp.regs);
diff --git a/arch/renesas/src/common/up_exit.c b/arch/renesas/src/common/up_exit.c
index 7e98ec5..03d5459 100644
--- a/arch/renesas/src/common/up_exit.c
+++ b/arch/renesas/src/common/up_exit.c
@@ -140,10 +140,6 @@ void _exit(int status)
nxsched_foreach(_up_dumponexit, NULL);
#endif
- /* Update scheduler parameters */
-
- nxsched_suspend_scheduler(tcb);
-
/* Destroy the task at the head of the ready to run list. */
nxtask_exit();
@@ -164,10 +160,6 @@ void _exit(int status)
group_addrenv(tcb);
#endif
- /* Reset scheduler parameters */
-
- nxsched_resume_scheduler(tcb);
-
/* Then switch contexts */
up_fullcontextrestore(tcb->xcp.regs);
diff --git a/arch/risc-v/src/common/riscv_exit.c b/arch/risc-v/src/common/riscv_exit.c
index 94b13b5..051558e 100644
--- a/arch/risc-v/src/common/riscv_exit.c
+++ b/arch/risc-v/src/common/riscv_exit.c
@@ -158,10 +158,6 @@ void _exit(int status)
nxsched_foreach(_up_dumponexit, NULL);
#endif
- /* Update scheduler parameters */
-
- nxsched_suspend_scheduler(tcb);
-
/* Destroy the task at the head of the ready to run list. */
nxtask_exit();
@@ -182,10 +178,6 @@ void _exit(int status)
group_addrenv(tcb);
#endif
- /* Reset scheduler parameters */
-
- nxsched_resume_scheduler(tcb);
-
/* Then switch contexts */
up_fullcontextrestore(tcb->xcp.regs);
diff --git a/arch/sim/src/sim/up_exit.c b/arch/sim/src/sim/up_exit.c
index 3e9b2b3..af83470 100644
--- a/arch/sim/src/sim/up_exit.c
+++ b/arch/sim/src/sim/up_exit.c
@@ -69,10 +69,6 @@ void _exit(int status)
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. */
nxtask_exit();
@@ -84,10 +80,6 @@ void _exit(int status)
tcb = this_task();
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
* a kludge. This would be unsafe in a truly multi-threaded, interrupt
* driven environment.
diff --git a/arch/x86/src/common/up_exit.c b/arch/x86/src/common/up_exit.c
index 2a3ef19..95533a2 100644
--- a/arch/x86/src/common/up_exit.c
+++ b/arch/x86/src/common/up_exit.c
@@ -140,10 +140,6 @@ void _exit(int status)
nxsched_foreach(_up_dumponexit, NULL);
#endif
- /* Update scheduler parameters */
-
- nxsched_suspend_scheduler(tcb);
-
/* Destroy the task at the head of the ready to run list. */
nxtask_exit();
@@ -164,10 +160,6 @@ void _exit(int status)
group_addrenv(tcb);
#endif
- /* Reset scheduler parameters */
-
- nxsched_resume_scheduler(tcb);
-
/* Then switch contexts */
up_fullcontextrestore(tcb->xcp.regs);
diff --git a/arch/x86_64/src/common/up_exit.c b/arch/x86_64/src/common/up_exit.c
index eec9a64..cd55324 100644
--- a/arch/x86_64/src/common/up_exit.c
+++ b/arch/x86_64/src/common/up_exit.c
@@ -135,7 +135,7 @@ void _exit(int status)
* 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());
@@ -146,7 +146,7 @@ void _exit(int status)
/* 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
* head of the list.
@@ -165,11 +165,10 @@ void _exit(int status)
* the ready-to-run list.
*/
- (void)group_addrenv(tcb);
+ group_addrenv(tcb);
#endif
/* Then switch contexts */
up_fullcontextrestore(tcb->xcp.regs);
}
-
diff --git a/arch/xtensa/src/common/xtensa_exit.c b/arch/xtensa/src/common/xtensa_exit.c
index 6c465ae..95ab3d5 100644
--- a/arch/xtensa/src/common/xtensa_exit.c
+++ b/arch/xtensa/src/common/xtensa_exit.c
@@ -157,10 +157,6 @@ void _exit(int status)
nxsched_foreach(_xtensa_dumponexit, NULL);
#endif
- /* Update scheduler parameters */
-
- nxsched_suspend_scheduler(tcb);
-
#if XCHAL_CP_NUM > 0
/* Disable co-processor support for the task that is exit-ing. */
@@ -193,10 +189,6 @@ void _exit(int status)
group_addrenv(tcb);
#endif
- /* Reset scheduler parameters */
-
- nxsched_resume_scheduler(tcb);
-
/* Then switch contexts */
xtensa_context_restore(tcb->xcp.regs);
diff --git a/arch/z16/src/common/z16_exit.c b/arch/z16/src/common/z16_exit.c
index d979cdf..6a7fc47 100644
--- a/arch/z16/src/common/z16_exit.c
+++ b/arch/z16/src/common/z16_exit.c
@@ -140,10 +140,6 @@ void _exit(int status)
nxsched_foreach(_z16_dumponexit, NULL);
#endif
- /* Update scheduler parameters */
-
- nxsched_suspend_scheduler(tcb);
-
/* Destroy the task at the head of the ready to run list. */
nxtask_exit();
@@ -155,10 +151,6 @@ void _exit(int status)
tcb = this_task();
sinfo("New Active Task TCB=%p\n", tcb);
- /* Reset scheduler parameters */
-
- nxsched_resume_scheduler(tcb);
-
/* Then switch contexts */
RESTORE_USERCONTEXT(tcb);
diff --git a/arch/z80/src/common/z80_exit.c b/arch/z80/src/common/z80_exit.c
index 51bf0a9..29f8887 100644
--- a/arch/z80/src/common/z80_exit.c
+++ b/arch/z80/src/common/z80_exit.c
@@ -142,10 +142,6 @@ void _exit(int status)
nxsched_foreach(_up_dumponexit, NULL);
#endif
- /* Update scheduler parameters */
-
- nxsched_suspend_scheduler(tcb);
-
/* Destroy the task at the head of the ready to run list. */
nxtask_exit();
@@ -167,10 +163,6 @@ void _exit(int status)
group_addrenv(tcb);
#endif
- /* Reset scheduler parameters */
-
- nxsched_resume_scheduler(tcb);
-
/* Then switch contexts */
RESTORE_USERCONTEXT(tcb);
diff --git a/sched/task/task_exit.c b/sched/task/task_exit.c
index 72dd1ea..831cb3a 100644
--- a/sched/task/task_exit.c
+++ b/sched/task/task_exit.c
@@ -84,6 +84,10 @@ int nxtask_exit(void)
dtcb = this_task();
#endif
+ /* Update scheduler parameters */
+
+ nxsched_suspend_scheduler(dtcb);
+
/* Remove the TCB of the current task from the ready-to-run list. A
* context switch will definitely be necessary -- that must be done
* by the architecture-specific logic.
@@ -102,13 +106,11 @@ int nxtask_exit(void)
rtcb = this_task();
#endif
-#ifdef CONFIG_SMP
/* Because clearing the global IRQ control in nxsched_remove_readytorun()
* was moved to nxsched_resume_scheduler(). So call the API here.
*/
nxsched_resume_scheduler(rtcb);
-#endif
/* 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-