Skip to content

Commit ba7dce8

Browse files
committed
[ipc] lockless rt_completion implementation
The new rt_completion implemented by lockless algorithm can improve timer resolution for up to ~12%, compare to sem IPC. Signed-off-by: Shell <[email protected]>
1 parent 89164b1 commit ba7dce8

File tree

11 files changed

+763
-113
lines changed

11 files changed

+763
-113
lines changed

Diff for: components/drivers/include/ipc/completion.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*
66
* Change Logs:
77
* Date Author Notes
8+
* 2024-04-28 Shell Add new wait_flags() & wakeup_by_errno() API
89
*/
910
#ifndef COMPLETION_H_
1011
#define COMPLETION_H_
@@ -13,7 +14,7 @@
1314
#include <rtconfig.h>
1415

1516
/**
16-
* Completion - A tiny IPC implementation for resource-constrained scenarios
17+
* Completion - A tiny & rapid IPC primitive for resource-constrained scenarios
1718
*
1819
* It's an IPC using one CPU word with the encoding:
1920
*
@@ -24,15 +25,17 @@
2425
struct rt_completion
2526
{
2627
/* suspended thread, and completed flag */
27-
rt_base_t susp_thread_n_flag;
28+
rt_atomic_t susp_thread_n_flag;
2829
};
2930

3031
#define RT_COMPLETION_INIT(comp) {0}
3132

3233
void rt_completion_init(struct rt_completion *completion);
3334
rt_err_t rt_completion_wait(struct rt_completion *completion,
3435
rt_int32_t timeout);
36+
rt_err_t rt_completion_wait_flags(struct rt_completion *completion,
37+
rt_int32_t timeout, int suspend_flag);
3538
void rt_completion_done(struct rt_completion *completion);
3639
rt_err_t rt_completion_wakeup(struct rt_completion *completion);
37-
40+
rt_err_t rt_completion_wakeup_by_errno(struct rt_completion *completion, rt_err_t error);
3841
#endif

0 commit comments

Comments
 (0)