57afaba4bb8be74b148dcc12e2930164a9cbb0de
4 * Userspace RCU library - test wfqueue race conditions
6 * Copyright 2023 - Olivier Dion <odion@efficios.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #define CDS_WFQ_DEPRECATED
30 #include <urcu/wfqueue.h>
35 #define NR_PRODUCERS 4
38 static void async_run(struct cds_wfq_queue
*queue
)
40 struct cds_wfq_node
*node
= malloc(sizeof(*node
));
42 cds_wfq_node_init(node
);
44 cds_wfq_enqueue(queue
, node
);
47 static void *async_loop(void *queue
)
51 while (k
< LOOP
* NR_PRODUCERS
) {
52 free(cds_wfq_dequeue_blocking(queue
));
59 static void *spawn_jobs(void *queue
)
61 for (size_t k
= 0; k
< LOOP
; ++k
) {
71 pthread_t producers
[NR_PRODUCERS
];
72 struct cds_wfq_queue queue
;
77 pthread_create(&consumer
, NULL
, async_loop
, &queue
);
79 for (size_t k
= 0; k
< NR_PRODUCERS
; ++k
) {
80 pthread_create(&producers
[k
], NULL
, spawn_jobs
, &queue
);
83 pthread_join(consumer
, NULL
);
84 for (size_t k
= 0; k
< NR_PRODUCERS
; ++k
) {
85 pthread_join(producers
[k
], NULL
);
88 ok1("No race conditions");
This page took 0.062453 seconds and 3 git commands to generate.