1111 * 2025-09-01 Rbb666 Add thread stack overflow hook.
1212 */
1313
14- #define DBG_TAG "kernel.sched"
15- #define DBG_LVL DBG_INFO
14+ #define DBG_TAG "kernel.sched"
15+ #define DBG_LVL DBG_INFO
1616#include <rtdbg.h>
1717
1818#include <rtthread.h>
3434void rt_sched_thread_init_ctx (struct rt_thread * thread , rt_uint32_t tick , rt_uint8_t priority )
3535{
3636 /* setup thread status */
37- RT_SCHED_CTX (thread ).stat = RT_THREAD_INIT ;
37+ RT_SCHED_CTX (thread ).stat = RT_THREAD_INIT ;
3838
3939#ifdef RT_USING_SMP
4040 /* not bind on any cpu */
@@ -258,9 +258,9 @@ rt_err_t rt_sched_thread_ready(struct rt_thread *thread)
258258 /* remove from suspend list */
259259 rt_list_remove (& RT_THREAD_LIST_NODE (thread ));
260260
261- #ifdef RT_USING_SMART
261+ #ifdef RT_USING_SMART
262262 thread -> wakeup_handle .func = RT_NULL ;
263- #endif
263+ #endif
264264
265265 /* insert to schedule ready list and remove from susp list */
266266 rt_sched_insert_thread (thread );
@@ -297,7 +297,7 @@ rt_err_t rt_sched_tick_increase(rt_tick_t tick)
297297
298298 rt_sched_lock (& slvl );
299299
300- if (RT_SCHED_PRIV (thread ).remaining_tick > tick )
300+ if (RT_SCHED_PRIV (thread ).remaining_tick > tick )
301301 {
302302 RT_SCHED_PRIV (thread ).remaining_tick -= tick ;
303303 }
@@ -474,7 +474,7 @@ void rt_scheduler_stack_check(struct rt_thread *thread)
474474
475475 /* if stack pointer locate in user data section skip stack check. */
476476 if (lwp && ((rt_uint32_t )thread -> sp > (rt_uint32_t )lwp -> data_entry &&
477- (rt_uint32_t )thread -> sp <= (rt_uint32_t )lwp -> data_entry + (rt_uint32_t )lwp -> data_size ))
477+ (rt_uint32_t )thread -> sp <= (rt_uint32_t )lwp -> data_entry + (rt_uint32_t )lwp -> data_size ))
478478 {
479479 return ;
480480 }
@@ -489,7 +489,7 @@ void rt_scheduler_stack_check(struct rt_thread *thread)
489489#endif /* ARCH_CPU_STACK_GROWS_UPWARD */
490490 (rt_uintptr_t )thread -> sp <= (rt_uintptr_t )thread -> stack_addr ||
491491 (rt_uintptr_t )thread -> sp >
492- (rt_uintptr_t )thread -> stack_addr + (rt_uintptr_t )thread -> stack_size )
492+ (rt_uintptr_t )thread -> stack_addr + (rt_uintptr_t )thread -> stack_size )
493493 {
494494 rt_base_t dummy = 1 ;
495495 rt_err_t hook_result = - RT_ERROR ;
@@ -506,7 +506,8 @@ void rt_scheduler_stack_check(struct rt_thread *thread)
506506 /* If hook handled the overflow successfully, don't enter infinite loop */
507507 if (hook_result != RT_EOK )
508508 {
509- while (dummy );
509+ while (dummy )
510+ ;
510511 }
511512 }
512513#endif /* RT_USING_HW_STACK_GUARD */
@@ -518,7 +519,7 @@ void rt_scheduler_stack_check(struct rt_thread *thread)
518519#endif
519520 {
520521 LOG_W ("warning: %s stack is close to the top of stack address.\n" ,
521- thread -> parent .name );
522+ thread -> parent .name );
522523 }
523524#else
524525#ifndef RT_USING_HW_STACK_GUARD
@@ -528,9 +529,9 @@ void rt_scheduler_stack_check(struct rt_thread *thread)
528529#endif
529530 {
530531 LOG_W ("warning: %s stack is close to end of stack address.\n" ,
531- thread -> parent .name );
532+ thread -> parent .name );
532533 }
533534#endif /* ARCH_CPU_STACK_GROWS_UPWARD */
534535}
535536
536- #endif /* RT_USING_OVERFLOW_CHECK */
537+ #endif /* RT_USING_OVERFLOW_CHECK */
0 commit comments