File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -860,17 +860,37 @@ do \
860860} \
861861while (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 ) \
869889do \
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__); \
You can’t perform that action at this time.
0 commit comments