wangchdo commented on code in PR #17043: URL: https://github.com/apache/nuttx/pull/17043#discussion_r2365652370
########## sched/sched/sched_suspendscheduler.c: ########## @@ -68,6 +68,12 @@ void nxsched_suspend_scheduler(FAR struct tcb_s *tcb) return; } +#ifdef CONFIG_TASK_STACK_OVERFLOW_CHECK + /* Check for stack overflow */ + + DEBUGASSERT(!up_check_tcbstack_overflow(tcb)); Review Comment: Do you mean `up_switch_context`? I don't think there is a function called nxsched_switch_context ...... I considered to use `up_switch_context` before, but because there are two problems described as below, you would find `nxsched_suspend_scheduler` is better, since both `up_switch_context` and `nxtask_exit` call it. 1. if using `up_switch_context` task exit will not be checked, like code below: ``` void up_exit(int status) { /* Destroy the task at the head of the ready to run list. */ nxtask_exit(); /* Update g_running_tasks */ #ifdef CONFIG_ARCH_ARMV6M /* ARMV6M syscal may trigger hard fault, We use * running_task != NULL to determine whether it is * a context for restoration. */ g_running_tasks[this_cpu()] = NULL; #else g_running_tasks[this_cpu()] = this_task(); #endif /* Then switch contexts */ arm_fullcontextrestore(); /* arm_fullcontextrestore() should not return but could if the software * interrupts are disabled. */ PANIC(); } ``` 2. up_switch_context is implemented in arch level, which means each arch code will need to call up_check_tcbstack_overflow -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org