1 // SPDX-FileCopyrightText: 2023 Olivier Dion <odion@efficios.com>
3 // SPDX-License-Identifier: GPL-2.0-or-later
8 * Userspace RCU library - test wftack race conditions
17 #include <urcu/lfstack.h>
22 #define NR_PRODUCERS 4
25 static void async_run(struct cds_lfs_stack
*queue
)
27 struct cds_lfs_node
*node
= malloc(sizeof(*node
));
29 cds_lfs_node_init(node
);
31 cds_lfs_push(queue
, node
);
34 static void *async_loop(void *queue
)
38 while (k
< LOOP
* NR_PRODUCERS
) {
39 free(cds_lfs_pop_blocking(queue
));
46 static void *spawn_jobs(void *queue
)
48 for (size_t k
= 0; k
< LOOP
; ++k
) {
58 pthread_t producers
[NR_PRODUCERS
];
59 struct cds_lfs_stack queue
;
64 pthread_create(&consumer
, NULL
, async_loop
, &queue
);
66 for (size_t k
= 0; k
< NR_PRODUCERS
; ++k
) {
67 pthread_create(&producers
[k
], NULL
, spawn_jobs
, &queue
);
70 pthread_join(consumer
, NULL
);
71 for (size_t k
= 0; k
< NR_PRODUCERS
; ++k
) {
72 pthread_join(producers
[k
], NULL
);
75 ok1("No race conditions");
This page took 0.041508 seconds and 4 git commands to generate.