4 * Userspace RCU library - test wftack 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 #include <urcu/wfstack.h>
34 #define NR_PRODUCERS 4
37 static void async_run(struct cds_wfs_stack
*queue
)
39 struct cds_wfs_node
*node
= malloc(sizeof(*node
));
41 cds_wfs_node_init(node
);
43 cds_wfs_push(queue
, node
);
46 static void *async_loop(void *queue
)
50 while (k
< LOOP
* NR_PRODUCERS
) {
51 free(cds_wfs_pop_blocking(queue
));
58 static void *spawn_jobs(void *queue
)
60 for (size_t k
= 0; k
< LOOP
; ++k
) {
70 pthread_t producers
[NR_PRODUCERS
];
71 struct cds_wfs_stack queue
;
76 pthread_create(&consumer
, NULL
, async_loop
, &queue
);
78 for (size_t k
= 0; k
< NR_PRODUCERS
; ++k
) {
79 pthread_create(&producers
[k
], NULL
, spawn_jobs
, &queue
);
82 pthread_join(consumer
, NULL
);
83 for (size_t k
= 0; k
< NR_PRODUCERS
; ++k
) {
84 pthread_join(producers
[k
], NULL
);
87 ok1("No race conditions");
This page took 0.030623 seconds and 4 git commands to generate.