mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 21:36:28 +08:00
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:
@@ -69,7 +69,6 @@ void up_exit(int status)
|
|||||||
|
|
||||||
/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases */
|
/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases */
|
||||||
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
g_running_tasks[this_cpu()] = tcb;
|
g_running_tasks[this_cpu()] = tcb;
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_ADDRENV
|
#ifdef CONFIG_ARCH_ADDRENV
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ void up_exit(int status)
|
|||||||
|
|
||||||
/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases */
|
/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases */
|
||||||
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
g_running_tasks[this_cpu()] = tcb;
|
g_running_tasks[this_cpu()] = tcb;
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_ADDRENV
|
#ifdef CONFIG_ARCH_ADDRENV
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ void up_exit(int status)
|
|||||||
|
|
||||||
/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases */
|
/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases */
|
||||||
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
g_running_tasks[this_cpu()] = tcb;
|
g_running_tasks[this_cpu()] = tcb;
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_ADDRENV
|
#ifdef CONFIG_ARCH_ADDRENV
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ void up_exit(int status)
|
|||||||
|
|
||||||
/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases */
|
/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases */
|
||||||
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
g_running_tasks[this_cpu()] = tcb;
|
g_running_tasks[this_cpu()] = tcb;
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_ADDRENV
|
#ifdef CONFIG_ARCH_ADDRENV
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ void up_exit(int status)
|
|||||||
* NOTE: the API also adjusts the global IRQ control for SMP
|
* NOTE: the API also adjusts the global IRQ control for SMP
|
||||||
*/
|
*/
|
||||||
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
g_running_tasks[this_cpu()] = tcb;
|
g_running_tasks[this_cpu()] = tcb;
|
||||||
|
|
||||||
/* Restore the cpu lock */
|
/* Restore the cpu lock */
|
||||||
|
|||||||
@@ -58,10 +58,6 @@ void up_exit(int status)
|
|||||||
{
|
{
|
||||||
struct tcb_s *tcb = this_task();
|
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. */
|
/* Destroy the task at the head of the ready to run list. */
|
||||||
|
|
||||||
(void)nxtask_exit();
|
(void)nxtask_exit();
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ void up_exit(int status)
|
|||||||
* NOTE: the API also adjusts the global IRQ control for SMP
|
* NOTE: the API also adjusts the global IRQ control for SMP
|
||||||
*/
|
*/
|
||||||
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
g_running_tasks[this_cpu()] = tcb;
|
g_running_tasks[this_cpu()] = tcb;
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_ADDRENV
|
#ifdef CONFIG_ARCH_ADDRENV
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ void up_exit(int status)
|
|||||||
* NOTE: the API also adjusts the global IRQ control for SMP
|
* NOTE: the API also adjusts the global IRQ control for SMP
|
||||||
*/
|
*/
|
||||||
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
g_running_tasks[this_cpu()] = tcb;
|
g_running_tasks[this_cpu()] = tcb;
|
||||||
|
|
||||||
/* Context switch, rearrange MMU */
|
/* Context switch, rearrange MMU */
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ void up_exit(int status)
|
|||||||
|
|
||||||
/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases */
|
/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases */
|
||||||
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
g_running_tasks[this_cpu()] = tcb;
|
g_running_tasks[this_cpu()] = tcb;
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ void up_exit(int status)
|
|||||||
|
|
||||||
/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases */
|
/* Adjusts time slice for SCHED_RR & SCHED_SPORADIC cases */
|
||||||
|
|
||||||
nxsched_resume_scheduler(tcb);
|
|
||||||
g_running_tasks[this_cpu()] = tcb;
|
g_running_tasks[this_cpu()] = tcb;
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_ADDRENV
|
#ifdef CONFIG_ARCH_ADDRENV
|
||||||
|
|||||||
@@ -1260,6 +1260,27 @@ void nxsched_suspend_scheduler(FAR struct tcb_s *tcb);
|
|||||||
# define nxsched_suspend_scheduler(tcb)
|
# define nxsched_suspend_scheduler(tcb)
|
||||||
#endif
|
#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
|
* Name: nxsched_get_param
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -90,10 +90,6 @@ int nxtask_exit(void)
|
|||||||
sinfo("%s pid=%d,TCB=%p\n", get_task_name(dtcb),
|
sinfo("%s pid=%d,TCB=%p\n", get_task_name(dtcb),
|
||||||
dtcb->pid, 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
|
/* 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.
|
||||||
@@ -112,12 +108,16 @@ int nxtask_exit(void)
|
|||||||
rtcb = this_task();
|
rtcb = this_task();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* NOTE: nxsched_resume_scheduler() was moved to up_exit()
|
/* Update scheduler parameters.
|
||||||
* because the global IRQ control for SMP should be deferred until
|
*
|
||||||
* context switching, otherwise, the context switching would be done
|
* When the thread exits, SYS_restore_context is called to
|
||||||
* without a critical section
|
* 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
|
/* 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-
|
||||||
* emption on this TCB and marking the new ready-to-run task as not
|
* emption on this TCB and marking the new ready-to-run task as not
|
||||||
|
|||||||
Reference in New Issue
Block a user