This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit ffafeb601cae0628e550fa76817de838cae5b097 Author: chenrun1 <[email protected]> AuthorDate: Wed Sep 4 17:10:53 2024 +0800 task_restart: restore critmon info Summary: When the child thread context switches during the switch interrupt, the parent thread calls task_restart on the child thread, which will cause critmon to count the interrupt duration of the child thread incorrectly. Therefore, we need to re-time the task each time we call task_restart. Assisted-By: mimo-v2.6-pro Co-authored-by: ouyangxiangzhen <[email protected]> Signed-off-by: chenrun1 <[email protected]> Signed-off-by: buxiasen <[email protected]> Signed-off-by: ouyangxiangzhen <[email protected]> --- sched/task/task_restart.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/sched/task/task_restart.c b/sched/task/task_restart.c index 29dd9c9f147..6c3ed1af3ef 100644 --- a/sched/task/task_restart.c +++ b/sched/task/task_restart.c @@ -267,6 +267,35 @@ static int nxtask_restart(pid_t pid) } #endif /* CONFIG_SMP */ + /* Reset critmon info */ + +#if CONFIG_SCHED_CRITMONITOR_MAXTIME_THREAD >= 0 + tcb->run_max = 0; + tcb->run_time = 0; +#endif + +#if CONFIG_SCHED_CRITMONITOR_MAXTIME_PREEMPTION >= 0 + tcb->preemp_start = 0; + tcb->preemp_max = 0; + tcb->preemp_caller = NULL; + tcb->preemp_max_caller = NULL; +#endif + +#if CONFIG_SCHED_CRITMONITOR_MAXTIME_CSECTION >= 0 + tcb->crit_start = 0; + tcb->crit_max = 0; + tcb->crit_caller = NULL; + tcb->crit_max_caller = NULL; +#endif + +#if CONFIG_SCHED_CRITMONITOR_MAXTIME_BUSYWAIT >= 0 + tcb->busywait_start = 0; + tcb->busywait_max = 0; + tcb->busywait_total = 0; + tcb->busywait_caller = NULL; + tcb->busywait_max_caller = NULL; +#endif + nxtask_reset_task(tcb, true); leave_critical_section(flags);
