You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/10/09 18:38:23 UTC
(nuttx) 05/07: sched/sched.h: add nxsched_lock/unlock_irq() function
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 39449c6069e2001046d25d59058c8c36af378f0e
Author: Bowen Wang <wa...@xiaomi.com>
AuthorDate: Fri May 24 14:30:07 2024 +0800
sched/sched.h: add nxsched_lock/unlock_irq() function
These two macros can be called in interrupt context and:
1. Do nothing when called in interrupt;
2. Same behavior as sched_lock/unlock when called in thread;
Signed-off-by: Bowen Wang <wa...@xiaomi.com>
---
include/nuttx/sched.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h
index 3103c715f1..df954ae7cc 100644
--- a/include/nuttx/sched.h
+++ b/include/nuttx/sched.h
@@ -242,6 +242,13 @@
# define this_cpu() (0)
#endif
+/* Task Switching Interfaces (non-standard).
+ * These two macros can be called in interrupt context.
+ */
+
+#define nxsched_lock_irq() (up_interrupt_context() ? OK : sched_lock())
+#define nxsched_unlock_irq() (up_interrupt_context() ? OK : sched_unlock())
+
/****************************************************************************
* Public Type Definitions
****************************************************************************/