Skip to content

Commit 2596ce7

Browse files
committed
feat(kernel): Check interrupt-disabled context in RT_DEBUG_SCHEDULER_AVAILABLE
1 parent 11a1348 commit 2596ce7

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
@@ -860,17 +860,37 @@ do \
860860
} \
861861
while (0)
862862

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

0 commit comments

Comments
 (0)