summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorShell <[email protected]>2024-05-16 15:45:12 +0800
committerGitHub <[email protected]>2024-05-16 15:45:12 +0800
commite25fc8b5118fba87acd5bc677641926a913bb3a5 (patch)
treed86b1be0152b2d3f360c83a3922d945f565ecaf0 /examples
parente46333496f880afe7ae2864967406f758aec55a7 (diff)
[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 <[email protected]> * fixup: RT_CPUS_NR --------- Signed-off-by: Shell <[email protected]>
Diffstat (limited to 'examples')
-rw-r--r--examples/utest/testcases/kernel/sched_sem_tc.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/examples/utest/testcases/kernel/sched_sem_tc.c b/examples/utest/testcases/kernel/sched_sem_tc.c
index a6302daba2..f071e143fe 100644
--- a/examples/utest/testcases/kernel/sched_sem_tc.c
+++ b/examples/utest/testcases/kernel/sched_sem_tc.c
@@ -29,7 +29,7 @@
#error the thread priority should at least be greater than idle
#endif
-static rt_atomic_t _star_counter = 1;
+static rt_atomic_t _star_counter;
static struct rt_semaphore _thr_exit_sem;
static struct rt_semaphore _level_waiting[TEST_LEVEL_COUNTS];
static rt_thread_t _thread_matrix[TEST_LEVEL_COUNTS][KERN_TEST_CONCURRENT_THREADS];
@@ -157,6 +157,8 @@ static void scheduler_tc(void)
static rt_err_t utest_tc_init(void)
{
LOG_I("Setup environment...");
+ _star_counter = 1;
+ rt_memset(_load_average, 0, sizeof(_load_average));
rt_sem_init(&_thr_exit_sem, "test", 0, RT_IPC_FLAG_PRIO);
for (size_t i = 0; i < TEST_LEVEL_COUNTS; i++)