From 3bd8506ae83deae4b41d1255b33503c8f81b6562 Mon Sep 17 00:00:00 2001 From: buxiasen Date: Thu, 11 Sep 2025 15:12:26 +0800 Subject: [PATCH] testing/ostest/roundrobin: add compatible for SMP Fix if SMP cause calculation run in multi-core cause case break. Signed-off-by: buxiasen --- testing/ostest/roundrobin.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/testing/ostest/roundrobin.c b/testing/ostest/roundrobin.c index 2735ba028..ed2f98ddb 100644 --- a/testing/ostest/roundrobin.c +++ b/testing/ostest/roundrobin.c @@ -160,6 +160,9 @@ void rr_test(void) bool test_passed = false; pthread_attr_t attr; pthread_addr_t result; +#ifdef CONFIG_SMP + cpu_set_t cpuset; +#endif int status; int i; @@ -199,6 +202,20 @@ void rr_test(void) printf("rr_test: Set thread policy to SCHED_RR\n"); } +#ifdef CONFIG_SMP + /* RR case on SMP only run on core0 */ + + CPU_ZERO(&cpuset); + CPU_SET(0, &cpuset); + status = pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpuset); + if (status != OK) + { + printf("rr_test: ERROR: pthread_attr_setaffinity_np failed," + " status=%d\n", status); + ASSERT(false); + } +#endif + /* This semaphore will prevent anything from running until we are ready */ sched_lock();