summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorShell <[email protected]>2024-01-09 23:09:49 +0800
committerGitHub <[email protected]>2024-01-09 23:09:49 +0800
commitcc157baf23b3757b1741ca06da4bad45b5ff8ddc (patch)
tree70f9e8e36b4d9eb988978eb0fb8ff1113add269a /include
parentacaa23052f2d24de5cc5c389014ed8a8513e7311 (diff)
[kernel] fixup of data racing accessing percpu objects (#8475)
Signed-off-by: Shell <[email protected]>
Diffstat (limited to 'include')
-rw-r--r--include/rtthread.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/rtthread.h b/include/rtthread.h
index 93fd138334..7ccf3b56c6 100644
--- a/include/rtthread.h
+++ b/include/rtthread.h
@@ -835,6 +835,16 @@ while (0)
#define RT_DEBUG_SCHEDULER_AVAILABLE(need_check)
#endif /* RT_DEBUGING_CONTEXT */
+rt_inline rt_bool_t rt_in_thread_context(void)
+{
+ return rt_thread_self() != RT_NULL && rt_interrupt_get_nest() == 0;
+}
+
+rt_inline rt_bool_t rt_scheduler_is_available(void)
+{
+ return !rt_hw_interrupt_is_disabled() && rt_critical_level() == 0 && rt_in_thread_context();
+}
+
/**@}*/
#ifdef __cplusplus