1 // SPDX-FileCopyrightText: 2023 Olivier Dion <odion@efficios.com>
3 // SPDX-License-Identifier: GPL-2.0-or-later
8 * Userspace RCU library - test wfqueue race conditions
17 #define CDS_WFQ_DEPRECATED
18 #include <urcu/wfqueue.h>
23 #define NR_PRODUCERS 4
26 static void async_run(struct cds_wfq_queue
*queue
)
28 struct cds_wfq_node
*node
= malloc(sizeof(*node
));
30 cds_wfq_node_init(node
);
32 cds_wfq_enqueue(queue
, node
);
35 static void *async_loop(void *queue
)
39 while (k
< LOOP
* NR_PRODUCERS
) {
40 free(cds_wfq_dequeue_blocking(queue
));
47 static void *spawn_jobs(void *queue
)
49 for (size_t k
= 0; k
< LOOP
; ++k
) {
59 pthread_t producers
[NR_PRODUCERS
];
60 struct cds_wfq_queue queue
;
65 pthread_create(&consumer
, NULL
, async_loop
, &queue
);
67 for (size_t k
= 0; k
< NR_PRODUCERS
; ++k
) {
68 pthread_create(&producers
[k
], NULL
, spawn_jobs
, &queue
);
71 pthread_join(consumer
, NULL
);
72 for (size_t k
= 0; k
< NR_PRODUCERS
; ++k
) {
73 pthread_join(producers
[k
], NULL
);
76 ok1("No race conditions");
This page took 0.034143 seconds and 5 git commands to generate.