Skip to content

Commit 6503dfd

Browse files
committed
testing/ostest/roundrobin: add compatible for SMP
Fix if SMP cause calculation run in multi-core cause case break. Signed-off-by: buxiasen <[email protected]>
1 parent 6aebbc1 commit 6503dfd

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

testing/ostest/roundrobin.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ void rr_test(void)
160160
bool test_passed = false;
161161
pthread_attr_t attr;
162162
pthread_addr_t result;
163+
#ifdef CONFIG_SMP
164+
cpu_set_t cpuset;
165+
#endif
163166
int status;
164167
int i;
165168

@@ -199,6 +202,20 @@ void rr_test(void)
199202
printf("rr_test: Set thread policy to SCHED_RR\n");
200203
}
201204

205+
#ifdef CONFIG_SMP
206+
/* RR case on SMP only run on core0 */
207+
208+
CPU_ZERO(&cpuset);
209+
CPU_SET(0, &cpuset);
210+
status = pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpuset);
211+
if (status != OK)
212+
{
213+
printf("rr_test: ERROR: pthread_attr_setaffinity_np failed,"
214+
" status=%d\n", status);
215+
ASSERT(false);
216+
}
217+
#endif
218+
202219
/* This semaphore will prevent anything from running until we are ready */
203220

204221
sched_lock();

0 commit comments

Comments
 (0)