Skip to content

Commit

Permalink
arch: fix the sched parameter update when exiting
Browse files Browse the repository at this point in the history
Signed-off-by: buxiasen <[email protected]>
  • Loading branch information
jasonbu authored and xiaoxiang781216 committed Oct 8, 2024
1 parent 4e5a963 commit 0b38595
Show file tree
Hide file tree
Showing 20 changed files with 38 additions and 32 deletions.
6 changes: 6 additions & 0 deletions arch/arm/src/arm/arm_syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ uint32_t *arm_syscall(uint32_t *regs)

cpu = this_cpu();
tcb = current_task(cpu);

/* Update scheduler parameters */

nxsched_suspend_scheduler(g_running_tasks[cpu]);
nxsched_resume_scheduler(tcb);

g_running_tasks[cpu] = tcb;

/* Restore the cpu lock */
Expand Down
6 changes: 2 additions & 4 deletions arch/arm/src/common/arm_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,9 @@ void up_exit(int status)

tcb = this_task();

/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases
* NOTE: the API also adjusts the global IRQ control for SMP
*/
/* Scheduler parameters will update inside syscall */

nxsched_resume_scheduler(tcb);
g_running_tasks[this_cpu()] = NULL;

/* Then switch contexts */

Expand Down
6 changes: 2 additions & 4 deletions arch/arm64/src/common/arm64_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,9 @@ void up_exit(int status)

tcb = this_task();

/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases
* NOTE: the API also adjusts the global IRQ control for SMP
*/
/* Scheduler parameters will update inside syscall */

nxsched_resume_scheduler(tcb);
g_running_tasks[this_cpu()] = NULL;

/* Then switch contexts */

Expand Down
1 change: 1 addition & 0 deletions arch/avr/src/common/avr_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ void up_exit(int status)
/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases */

nxsched_resume_scheduler(tcb);
g_running_tasks[this_cpu()] = tcb;

#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously running
Expand Down
1 change: 1 addition & 0 deletions arch/hc/src/common/hc_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ void up_exit(int status)
/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases */

nxsched_resume_scheduler(tcb);
g_running_tasks[this_cpu()] = tcb;

#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously running
Expand Down
6 changes: 2 additions & 4 deletions arch/mips/src/common/mips_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,9 @@ void up_exit(int status)

tcb = this_task();

/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases
* NOTE: the API also adjusts the global IRQ control for SMP
*/
/* Scheduler parameters will update inside syscall */

nxsched_resume_scheduler(tcb);
g_running_tasks[this_cpu()] = NULL;

/* Then switch contexts */

Expand Down
2 changes: 1 addition & 1 deletion arch/misoc/src/lm32/lm32_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void up_exit(int status)

/* Adjusts time slice for RR & SPORADIC cases */

nxsched_resume_scheduler(tcb);
g_running_tasks[this_cpu()] = NULL;

/* Then switch contexts */

Expand Down
2 changes: 1 addition & 1 deletion arch/misoc/src/minerva/minerva_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void up_exit(int status)

/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases */

nxsched_resume_scheduler(tcb);
g_running_tasks[this_cpu()] = NULL;

/* Then switch contexts */

Expand Down
1 change: 1 addition & 0 deletions arch/or1k/src/common/or1k_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ void up_exit(int status)
/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases */

nxsched_resume_scheduler(tcb);
g_running_tasks[this_cpu()] = tcb;

#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously running
Expand Down
3 changes: 2 additions & 1 deletion arch/renesas/src/common/renesas_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ void up_exit(int status)

tcb = this_task();

/* Adjusts time slice for RR & SPORADIC cases */
/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases */

nxsched_resume_scheduler(tcb);
g_running_tasks[this_cpu()] = tcb;

#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously running
Expand Down
8 changes: 1 addition & 7 deletions arch/risc-v/src/common/riscv_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,7 @@ void up_exit(int status)

tcb = this_task();

/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases
* NOTE: the API also adjusts the global IRQ control for SMP
*/

nxsched_resume_scheduler(tcb);

/* g_running_tasks is not valid now */
/* Scheduler parameters will update inside syscall */

g_running_tasks[this_cpu()] = NULL;

Expand Down
1 change: 1 addition & 0 deletions arch/sim/src/sim/sim_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ void up_exit(int status)
*/

nxsched_resume_scheduler(tcb);
g_running_tasks[this_cpu()] = tcb;

/* Restore the cpu lock */

Expand Down
4 changes: 2 additions & 2 deletions arch/sparc/src/common/sparc_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ void up_exit(int status)

tcb = this_task();

/* Reset scheduler parameters */
/* Scheduler parameters will update inside syscall */

nxsched_resume_scheduler(tcb);
g_running_tasks[this_cpu()] = NULL;

/* Then switch contexts */

Expand Down
6 changes: 2 additions & 4 deletions arch/tricore/src/common/tricore_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,9 @@ void up_exit(int status)

tcb = this_task();

/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases
* NOTE: the API also adjusts the global IRQ control for SMP
*/
/* Scheduler parameters will update inside syscall */

nxsched_resume_scheduler(tcb);
g_running_tasks[this_cpu()] = NULL;

/* Then switch contexts */

Expand Down
1 change: 1 addition & 0 deletions arch/x86/src/common/x86_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void up_exit(int status)
*/

nxsched_resume_scheduler(tcb);
g_running_tasks[this_cpu()] = tcb;

#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously running
Expand Down
1 change: 1 addition & 0 deletions arch/x86_64/src/common/x86_64_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ void up_exit(int status)
*/

nxsched_resume_scheduler(tcb);
g_running_tasks[this_cpu()] = tcb;

/* Context switch, rearrange MMU */

Expand Down
6 changes: 2 additions & 4 deletions arch/xtensa/src/common/xtensa_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,9 @@ void up_exit(int status)

tcb = this_task();

/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases
* NOTE: the API also adjusts the global IRQ control for SMP
*/
/* Scheduler parameters will update inside syscall */

nxsched_resume_scheduler(tcb);
g_running_tasks[this_cpu()] = NULL;

/* Then switch contexts */

Expand Down
1 change: 1 addition & 0 deletions arch/z16/src/common/z16_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ void up_exit(int status)
/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases */

nxsched_resume_scheduler(tcb);
g_running_tasks[this_cpu()] = tcb;

/* Then switch contexts */

Expand Down
1 change: 1 addition & 0 deletions arch/z80/src/common/z80_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void up_exit(int status)
/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases */

nxsched_resume_scheduler(tcb);
g_running_tasks[this_cpu()] = tcb;

#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously running
Expand Down
7 changes: 7 additions & 0 deletions sched/sched/sched_suspendscheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@

void nxsched_suspend_scheduler(FAR struct tcb_s *tcb)
{
/* Handle the task exiting case */

if (tcb != NULL)
{
return;
}

#ifdef CONFIG_SCHED_SPORADIC
/* Perform sporadic schedule operations */

Expand Down

0 comments on commit 0b38595

Please sign in to comment.