Skip to content

Commit bf6c4d0

Browse files
Merge pull request #349 from insertinterestingnamehere/hang
Atomics For Spinning Waiter in qthread_readstate Test
2 parents 0d91c7e + f8fcfbd commit bf6c4d0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Diff for: test/basics/qthread_readstate.c

+7-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
} while (0)
1616

1717
static aligned_t spinner(void *arg) {
18-
while (*(aligned_t *)arg == 0);
18+
while (atomic_load_explicit((_Atomic aligned_t *)arg, memory_order_relaxed) ==
19+
0);
1920
return 1;
2021
}
2122

@@ -32,11 +33,12 @@ int main(int argc, char *argv[]) {
3233

3334
TEST_OPTION(STACK_SIZE, >=, 2048);
3435
{
35-
aligned_t r = 0;
36+
_Atomic aligned_t r;
37+
atomic_store_explicit(&r, 0u, memory_order_relaxed);
3638
TEST_OPTION(BUSYNESS, ==, 1); // Just this thread
3739
TEST_OPTION(NODE_BUSYNESS, ==, 1);
3840
TEST_OPTION(WORKER_OCCUPATION, ==, 1);
39-
qthread_fork(spinner, &r, &r);
41+
qthread_fork(spinner, (void *)&r, (aligned_t *)&r);
4042
qthread_flushsc();
4143
TEST_OPTION(BUSYNESS, >=, 1);
4244
TEST_OPTION(BUSYNESS, <=, 2);
@@ -45,8 +47,8 @@ int main(int argc, char *argv[]) {
4547
TEST_OPTION(NODE_BUSYNESS, <=, 2);
4648
TEST_OPTION(WORKER_OCCUPATION, >=, 1);
4749
TEST_OPTION(WORKER_OCCUPATION, <=, 2);
48-
r = 1;
49-
qthread_readFF(NULL, &r);
50+
atomic_store_explicit(&r, 1u, memory_order_relaxed);
51+
qthread_readFF(NULL, (aligned_t *)&r);
5052
}
5153
{
5254
size_t sheps;

0 commit comments

Comments
 (0)