summaryrefslogtreecommitdiff
path: root/include/rtdebug.h
diff options
context:
space:
mode:
authorguozhanxin <[email protected]>2022-01-26 16:02:24 +0800
committerguozhanxin <[email protected]>2022-01-26 16:03:31 +0800
commit9b44535740b7e1deda584e8c7397b40113fa43f0 (patch)
tree7f318dcfbf7a8f01da544e909653a5601e4d13a6 /include/rtdebug.h
parente665bacf89c5901244cd43e195a7ae039b3c0463 (diff)
add RT_DEBUG_SCHEDULER_AVAILABLE check
Diffstat (limited to 'include/rtdebug.h')
-rw-r--r--include/rtdebug.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/rtdebug.h b/include/rtdebug.h
index 0858a5bbf1..143f6c29d4 100644
--- a/include/rtdebug.h
+++ b/include/rtdebug.h
@@ -110,9 +110,31 @@ do \
rt_hw_interrupt_enable(level); \
} \
while (0)
+
+/* "scheduler available" means:
+ * 1) the scheduler has been started.
+ * 2) not in interrupt context.
+ * 3) scheduler is not locked.
+ */
+#define RT_DEBUG_SCHEDULER_AVAILABLE \
+do \
+{ \
+ rt_base_t level; \
+ level = rt_hw_interrupt_disable(); \
+ if (rt_critical_level() != 0) \
+ { \
+ rt_kprintf("Function[%s]: scheduler is not available\n", \
+ __FUNCTION__); \
+ RT_ASSERT(0) \
+ } \
+ RT_DEBUG_IN_THREAD_CONTEXT; \
+ rt_hw_interrupt_enable(level); \
+} \
+while (0)
#else
#define RT_DEBUG_NOT_IN_INTERRUPT
#define RT_DEBUG_IN_THREAD_CONTEXT
+#define RT_DEBUG_SCHEDULER_AVAILABLE
#endif
#else /* RT_DEBUG */
@@ -121,6 +143,7 @@ while (0)
#define RT_DEBUG_LOG(type, message)
#define RT_DEBUG_NOT_IN_INTERRUPT
#define RT_DEBUG_IN_THREAD_CONTEXT
+#define RT_DEBUG_SCHEDULER_AVAILABLE
#endif /* RT_DEBUG */