Skip to content

Commit 4ec8373

Browse files
wdfk-progRbb666
authored andcommitted
feat(kernel): Check interrupt-disabled context in RT_DEBUG_SCHEDULER_AVAILABLE
1 parent 630f4fa commit 4ec8373

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

include/rtthread.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,17 +861,37 @@ do \
861861
} \
862862
while (0)
863863

864+
#if defined(RT_USING_SMP)
865+
/**
866+
* @brief Check whether disabled interrupts make scheduler unavailable.
867+
*
868+
* In SMP builds, some kernel-internal lockless wait paths may disable local
869+
* interrupts while still using scheduler-related operations legally. Keep this
870+
* IRQ-disabled context assertion for UP builds only.
871+
*/
872+
#define RT_DEBUG_SCHEDULER_IRQ_DISABLED() (RT_FALSE)
873+
#else
874+
/**
875+
* @brief Check whether disabled interrupts make scheduler unavailable.
876+
*
877+
* In UP builds, globally disabled interrupts prevent normal scheduling and
878+
* timeout progress, so blocking scheduler paths must reject this context.
879+
*/
880+
#define RT_DEBUG_SCHEDULER_IRQ_DISABLED() rt_hw_interrupt_is_disabled()
881+
#endif /* defined(RT_USING_SMP) */
882+
864883
/* "scheduler available" means:
865884
* 1) the scheduler has been started.
866885
* 2) not in interrupt context.
867886
* 3) scheduler is not locked.
887+
* 4) interrupts are not disabled on UP.
868888
*/
869889
#define RT_DEBUG_SCHEDULER_AVAILABLE(need_check) \
870890
do \
871891
{ \
872892
if (need_check) \
873893
{ \
874-
if (rt_critical_level() != 0) \
894+
if ((rt_critical_level() != 0) || RT_DEBUG_SCHEDULER_IRQ_DISABLED()) \
875895
{ \
876896
rt_kprintf("Function[%s]: scheduler is not available\n", \
877897
__FUNCTION__); \

0 commit comments

Comments
 (0)