mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-21 10:36:04 +08:00
[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 <smokewood@qq.com> * fixup: RT_CPUS_NR --------- Signed-off-by: Shell <smokewood@qq.com>
This commit is contained in:
+1
-1
@@ -146,7 +146,7 @@ rt_base_t rt_cpus_lock(void)
|
||||
pcpu = rt_cpu_self();
|
||||
if (pcpu->current_thread != RT_NULL)
|
||||
{
|
||||
register rt_ubase_t lock_nest = rt_atomic_load(&(pcpu->current_thread->cpus_lock_nest));
|
||||
rt_ubase_t lock_nest = rt_atomic_load(&(pcpu->current_thread->cpus_lock_nest));
|
||||
|
||||
rt_atomic_add(&(pcpu->current_thread->cpus_lock_nest), 1);
|
||||
if (lock_nest == 0)
|
||||
|
||||
@@ -1089,6 +1089,7 @@ void rt_exit_critical_safe(rt_base_t critical_level)
|
||||
|
||||
void rt_exit_critical_safe(rt_base_t critical_level)
|
||||
{
|
||||
RT_UNUSED(critical_level);
|
||||
return rt_exit_critical();
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user