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