diff options
| author | guozhanxin <[email protected]> | 2022-01-26 16:02:24 +0800 |
|---|---|---|
| committer | guozhanxin <[email protected]> | 2022-01-26 16:03:31 +0800 |
| commit | 9b44535740b7e1deda584e8c7397b40113fa43f0 (patch) | |
| tree | 7f318dcfbf7a8f01da544e909653a5601e4d13a6 /include | |
| parent | e665bacf89c5901244cd43e195a7ae039b3c0463 (diff) | |
add RT_DEBUG_SCHEDULER_AVAILABLE check
Diffstat (limited to 'include')
| -rw-r--r-- | include/rtdebug.h | 23 |
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 */ |
