From c451dce8203fb2616d6ec4634db1f4a7b766680c Mon Sep 17 00:00:00 2001 From: Shell Date: Thu, 15 Aug 2024 21:30:58 +0800 Subject: feat: add ISR safe completion API Since the completion is used to sync with ISR mostly, we should set the default semantic to ISR-safe. So most user will be happy and don't see any weird behavior in their codes. Changes: - Added `rt_completion_wait_noisr` and `rt_completion_wait_flags_noisr` functions in `completion.h`, `completion_comm.c`, `completion_mp.c`, and `completion_up.c`. - The new APIs allow waiting for completions in non-ISR contexts while ensuring thread context safety. - Existing documentation and comments were updated to clarify usage contexts and emphasize restrictions on ISR usage. Signed-off-by: Shell --- components/drivers/include/ipc/completion.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'components/drivers/include') diff --git a/components/drivers/include/ipc/completion.h b/components/drivers/include/ipc/completion.h index 30f4acf81c..bc075c410c 100644 --- a/components/drivers/include/ipc/completion.h +++ b/components/drivers/include/ipc/completion.h @@ -14,9 +14,9 @@ #include /** - * Completion - A tiny & rapid IPC primitive for resource-constrained scenarios + * RT-Completion - A Tiny(resource-constrained) & Rapid(lockless) IPC Primitive * - * It's an IPC using one CPU word with the encoding: + * It's an IPC using one pointer word with the encoding: * * BIT | MAX-1 ----------------- 1 | 0 | * CONTENT | suspended_thread & ~1 | completed flag | @@ -33,8 +33,12 @@ struct rt_completion void rt_completion_init(struct rt_completion *completion); rt_err_t rt_completion_wait(struct rt_completion *completion, rt_int32_t timeout); +rt_err_t rt_completion_wait_noisr(struct rt_completion *completion, + rt_int32_t timeout); rt_err_t rt_completion_wait_flags(struct rt_completion *completion, rt_int32_t timeout, int suspend_flag); +rt_err_t rt_completion_wait_flags_noisr(struct rt_completion *completion, + rt_int32_t timeout, int suspend_flag); void rt_completion_done(struct rt_completion *completion); rt_err_t rt_completion_wakeup(struct rt_completion *completion); rt_err_t rt_completion_wakeup_by_errno(struct rt_completion *completion, rt_err_t error); -- cgit v1.3.1