summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorwdfk-prog <[email protected]>2026-04-27 09:02:49 +0800
committerRbb666 <[email protected]>2026-05-19 09:36:16 +0800
commit4ec8373caaf2be9bf1dd67f7057bd7c0d58484de (patch)
tree9a901b84181049083f597e22bad9cf0011150c1a /include
parent630f4fa7a37ca99af5952946eea327cf9f1df21c (diff)
feat(kernel): Check interrupt-disabled context in RT_DEBUG_SCHEDULER_AVAILABLE
Diffstat (limited to 'include')
-rw-r--r--include/rtthread.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/include/rtthread.h b/include/rtthread.h
index 486ad7a302..177ea87783 100644
--- a/include/rtthread.h
+++ b/include/rtthread.h
@@ -861,17 +861,37 @@ do \
} \
while (0)
+#if defined(RT_USING_SMP)
+/**
+ * @brief Check whether disabled interrupts make scheduler unavailable.
+ *
+ * In SMP builds, some kernel-internal lockless wait paths may disable local
+ * interrupts while still using scheduler-related operations legally. Keep this
+ * IRQ-disabled context assertion for UP builds only.
+ */
+#define RT_DEBUG_SCHEDULER_IRQ_DISABLED() (RT_FALSE)
+#else
+/**
+ * @brief Check whether disabled interrupts make scheduler unavailable.
+ *
+ * In UP builds, globally disabled interrupts prevent normal scheduling and
+ * timeout progress, so blocking scheduler paths must reject this context.
+ */
+#define RT_DEBUG_SCHEDULER_IRQ_DISABLED() rt_hw_interrupt_is_disabled()
+#endif /* defined(RT_USING_SMP) */
+
/* "scheduler available" means:
* 1) the scheduler has been started.
* 2) not in interrupt context.
* 3) scheduler is not locked.
+ * 4) interrupts are not disabled on UP.
*/
#define RT_DEBUG_SCHEDULER_AVAILABLE(need_check) \
do \
{ \
if (need_check) \
{ \
- if (rt_critical_level() != 0) \
+ if ((rt_critical_level() != 0) || RT_DEBUG_SCHEDULER_IRQ_DISABLED()) \
{ \
rt_kprintf("Function[%s]: scheduler is not available\n", \
__FUNCTION__); \