Skip to content

Commit 56b335a

Browse files
author
Christopher Friedt
committed
tests: posix: common: add a small delay in pthread_descriptor_leak
Technically speaking, there should be a synchronization to ensure that a spawned thread has started before `pthread_join()` is called. However, since we're recycling an existing no-op thread, just add a small delay. A separate test will be used to demonstrate stressing `pthread_create()` and `pthread_join()` which will use a synchronization primitive. Signed-off-by: Christopher Friedt <[email protected]>
1 parent 0231ff5 commit 56b335a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tests/posix/common/src/pthread.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,8 @@ ZTEST(posix_apis, test_pthread_descriptor_leak)
594594
for (size_t i = 0; i < CONFIG_MAX_PTHREAD_COUNT * 2; ++i) {
595595
zassert_ok(pthread_create(&pthread1, &attr, create_thread1, NULL),
596596
"unable to create thread %zu", i);
597+
/* Small delay to prevent joining before the thread has been spawned */
598+
k_msleep(100);
597599
zassert_ok(pthread_join(pthread1, NULL), "unable to join thread %zu", i);
598600
}
599601
}

0 commit comments

Comments
 (0)