arch: unify the scheduling information of task_exit
Replace all nxsched_suspend/resume_*** with nxsched_switch_context Delete nxsched_resume_scheduler in up_exit and call it uniformly in task_exit Co-authored-by: yinshengkai <yinshengkai@xiaomi.com> Signed-off-by: guoshengyuan1 <guoshengyuan1@xiaomi.com>
This commit is contained in:
parent
95efa6f7cf
commit
fc15b8da8a
12 changed files with 29 additions and 21 deletions
|
|
@ -69,7 +69,6 @@ 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
|
||||
|
|
|
|||
|
|
@ -68,7 +68,6 @@ 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
|
||||
|
|
|
|||
|
|
@ -70,7 +70,6 @@ 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
|
||||
|
|
|
|||
|
|
@ -68,7 +68,6 @@ 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
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ void up_exit(int status)
|
|||
* NOTE: the API also adjusts the global IRQ control for SMP
|
||||
*/
|
||||
|
||||
nxsched_resume_scheduler(tcb);
|
||||
g_running_tasks[this_cpu()] = tcb;
|
||||
|
||||
/* Restore the cpu lock */
|
||||
|
|
|
|||
|
|
@ -58,10 +58,6 @@ void up_exit(int status)
|
|||
{
|
||||
struct tcb_s *tcb = this_task();
|
||||
|
||||
/* Update scheduler parameters */
|
||||
|
||||
nxsched_suspend_scheduler(tcb);
|
||||
|
||||
/* Destroy the task at the head of the ready to run list. */
|
||||
|
||||
(void)nxtask_exit();
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@ void up_exit(int status)
|
|||
* NOTE: the API also adjusts the global IRQ control for SMP
|
||||
*/
|
||||
|
||||
nxsched_resume_scheduler(tcb);
|
||||
g_running_tasks[this_cpu()] = tcb;
|
||||
|
||||
#ifdef CONFIG_ARCH_ADDRENV
|
||||
|
|
|
|||
|
|
@ -70,7 +70,6 @@ void up_exit(int status)
|
|||
* NOTE: the API also adjusts the global IRQ control for SMP
|
||||
*/
|
||||
|
||||
nxsched_resume_scheduler(tcb);
|
||||
g_running_tasks[this_cpu()] = tcb;
|
||||
|
||||
/* Context switch, rearrange MMU */
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ 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 */
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@ 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
|
||||
|
|
|
|||
|
|
@ -1260,6 +1260,27 @@ void nxsched_suspend_scheduler(FAR struct tcb_s *tcb);
|
|||
# define nxsched_suspend_scheduler(tcb)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsched_switch_context
|
||||
*
|
||||
* Description:
|
||||
* This function is used to switch context between two tasks.
|
||||
*
|
||||
* Input Parameters:
|
||||
* from - The TCB of the task to be suspended.
|
||||
* to - The TCB of the task to be resumed.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
****************************************************************************/
|
||||
|
||||
static inline void nxsched_switch_context(FAR struct tcb_s *from,
|
||||
FAR struct tcb_s *to)
|
||||
{
|
||||
nxsched_suspend_scheduler(from);
|
||||
nxsched_resume_scheduler(to);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsched_get_param
|
||||
*
|
||||
|
|
|
|||
|
|
@ -90,10 +90,6 @@ int nxtask_exit(void)
|
|||
sinfo("%s pid=%d,TCB=%p\n", get_task_name(dtcb),
|
||||
dtcb->pid, dtcb);
|
||||
|
||||
/* 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.
|
||||
|
|
@ -112,12 +108,16 @@ int nxtask_exit(void)
|
|||
rtcb = this_task();
|
||||
#endif
|
||||
|
||||
/* NOTE: nxsched_resume_scheduler() was moved to up_exit()
|
||||
* because the global IRQ control for SMP should be deferred until
|
||||
* context switching, otherwise, the context switching would be done
|
||||
* without a critical section
|
||||
/* Update scheduler parameters.
|
||||
*
|
||||
* When the thread exits, SYS_restore_context is called to
|
||||
* restore the context, which does not update the scheduling
|
||||
* information.
|
||||
* We need to update the scheduling information before tcb is released.
|
||||
*/
|
||||
|
||||
nxsched_switch_context(dtcb, rtcb);
|
||||
|
||||
/* 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-
|
||||
* emption on this TCB and marking the new ready-to-run task as not
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue