17901cec1c2bc0846e0a1ce68889da24b1cde338
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/wfstack.h>
22 #define NR_PRODUCERS 4
25 static void async_run(struct cds_wfs_stack
*queue
)
27 struct cds_wfs_node
*node
= malloc(sizeof(*node
));
29 cds_wfs_node_init(node
);
31 cds_wfs_push(queue
, node
);
34 static void *async_loop(void *queue
)
38 while (k
< LOOP
* NR_PRODUCERS
) {
39 free(cds_wfs_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_wfs_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.032488 seconds and 3 git commands to generate.