From e25fc8b5118fba87acd5bc677641926a913bb3a5 Mon Sep 17 00:00:00 2001 From: Shell Date: Thu, 16 May 2024 15:45:12 +0800 Subject: [libcpu/arm64] add C11 atomic ticket spinlock (#8882) * [libcpu/arm64] add C11 atomic ticket spinlock Replace the former implementation of flag-based spinlock which is unfair Besides, C11 atomic implementation is more readable (it's C anyway), and maintainable. Cause toolchain can use their builtin optimization and tune for different micro-architectures. For example armv8.5 introduces a better instruction. The compiler can help with that when it knows your target platform in support of it. Signed-off-by: Shell * fixup: RT_CPUS_NR --------- Signed-off-by: Shell --- src/thread.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/thread.c') diff --git a/src/thread.c b/src/thread.c index 77f65bc68b..8d4752409d 100644 --- a/src/thread.c +++ b/src/thread.c @@ -363,7 +363,8 @@ rt_thread_t rt_thread_self(void) self = rt_cpu_self()->current_thread; rt_hw_local_irq_enable(lock); return self; -#else + +#else /* !RT_USING_SMP */ extern rt_thread_t rt_current_thread; return rt_current_thread; -- cgit v1.3.1