mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 14:27:37 +08:00
arm64: remove g_running_tasks[this_cpu()] = NULL
reason: We hope to keep g_running_tasks valid forever. Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
@@ -65,7 +65,7 @@ void up_exit(int status)
|
|||||||
|
|
||||||
/* Scheduler parameters will update inside syscall */
|
/* Scheduler parameters will update inside syscall */
|
||||||
|
|
||||||
g_running_tasks[this_cpu()] = NULL;
|
g_running_tasks[this_cpu()] = this_task();
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
|
|||||||
@@ -161,6 +161,5 @@ retry:
|
|||||||
rtcb->irqcount--;
|
rtcb->irqcount--;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_running_tasks[this_cpu()] = NULL;
|
|
||||||
arm64_fullcontextrestore();
|
arm64_fullcontextrestore();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,11 +162,6 @@ uint64_t *arm64_syscall(uint64_t *regs)
|
|||||||
uint64_t spsr;
|
uint64_t spsr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (*running_task != NULL)
|
|
||||||
{
|
|
||||||
(*running_task)->xcp.regs = regs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Nested interrupts are not supported */
|
/* Nested interrupts are not supported */
|
||||||
|
|
||||||
DEBUGASSERT(regs);
|
DEBUGASSERT(regs);
|
||||||
@@ -175,41 +170,40 @@ uint64_t *arm64_syscall(uint64_t *regs)
|
|||||||
|
|
||||||
cmd = regs[REG_X0];
|
cmd = regs[REG_X0];
|
||||||
|
|
||||||
|
/* if cmd == SYS_restore_context (*running_task)->xcp.regs is valid
|
||||||
|
* should not be overwriten
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (cmd != SYS_restore_context)
|
||||||
|
{
|
||||||
|
(*running_task)->xcp.regs = regs;
|
||||||
|
}
|
||||||
|
|
||||||
arm64_dump_syscall(__func__, cmd, regs);
|
arm64_dump_syscall(__func__, cmd, regs);
|
||||||
|
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
/* x0 = SYS_restore_context: Restore task context
|
|
||||||
*
|
|
||||||
* void arm64_fullcontextrestore(uint64_t *restoreregs)
|
|
||||||
* noreturn_function;
|
|
||||||
*
|
|
||||||
* At this point, the following values are saved in context:
|
|
||||||
*
|
|
||||||
* x0 = SYS_restore_context
|
|
||||||
* x1 = next
|
|
||||||
*/
|
|
||||||
|
|
||||||
case SYS_restore_context:
|
case SYS_restore_context:
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
nxsched_resume_scheduler(tcb);
|
||||||
|
|
||||||
|
/* Restore the cpu lock */
|
||||||
|
|
||||||
|
restore_critical_section(tcb, cpu);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* x0 = SYS_switch_context: This a switch context command:
|
|
||||||
*
|
|
||||||
* void arm64_switchcontext(struct tcb_s *prev, struct tcb_s *next);
|
|
||||||
*
|
|
||||||
* At this point, the following values are saved in context:
|
|
||||||
*
|
|
||||||
* x0 = SYS_switch_context
|
|
||||||
* x1 = prev
|
|
||||||
* x2 = next
|
|
||||||
*
|
|
||||||
* In this case, we do both: We save the context registers to the save
|
|
||||||
* register area reference by the saved contents of x1 and then set
|
|
||||||
* regs to the save register area referenced by the saved
|
|
||||||
* contents of x2.
|
|
||||||
*/
|
|
||||||
|
|
||||||
case SYS_switch_context:
|
case SYS_switch_context:
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
nxsched_suspend_scheduler(*running_task);
|
||||||
|
nxsched_resume_scheduler(tcb);
|
||||||
|
*running_task = tcb;
|
||||||
|
|
||||||
|
/* Restore the cpu lock */
|
||||||
|
|
||||||
|
restore_critical_section(tcb, cpu);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef CONFIG_BUILD_KERNEL
|
#ifdef CONFIG_BUILD_KERNEL
|
||||||
@@ -321,10 +315,6 @@ uint64_t *arm64_syscall(uint64_t *regs)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*running_task != tcb)
|
|
||||||
{
|
|
||||||
tcb = current_task(cpu);
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_ADDRENV
|
#ifdef CONFIG_ARCH_ADDRENV
|
||||||
/* Make sure that the address environment for the previously
|
/* Make sure that the address environment for the previously
|
||||||
* running task is closed down gracefully (data caches dump,
|
* running task is closed down gracefully (data caches dump,
|
||||||
@@ -332,24 +322,11 @@ uint64_t *arm64_syscall(uint64_t *regs)
|
|||||||
* thread at the head of the ready-to-run list.
|
* thread at the head of the ready-to-run list.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (SYS_restore_context == cmd || SYS_switch_context == cmd)
|
||||||
|
{
|
||||||
addrenv_switch(NULL);
|
addrenv_switch(NULL);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(*running_task);
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Record the new "running" task. g_running_tasks[] is only used by
|
|
||||||
* assertion logic for reporting crashes.
|
|
||||||
*/
|
|
||||||
|
|
||||||
*running_task = tcb;
|
|
||||||
|
|
||||||
/* Restore the cpu lock */
|
|
||||||
|
|
||||||
restore_critical_section(tcb, cpu);
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return tcb->xcp.regs;
|
return tcb->xcp.regs;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user