# SPDX-License-Identifier: MIT
AM_CPPFLAGS += -I$(top_srcdir)/src -I$(top_srcdir)/tests/common
+AM_CPPFLAGS += -include $(top_srcdir)/tests/benchmark/common-states.h
TEST_EXTENSIONS = .tap
TAP_LOG_DRIVER_FLAGS = --merge --comments
URCU_TESTS_BUILDDIR='$(abs_top_builddir)/tests' \
$(SHELL) $(top_srcdir)/tests/utils/tap-driver.sh
+noinst_HEADERS = common-states.h
+
SCRIPT_LIST = \
runpaul-phase1.sh \
runpaul-phase2.sh \
DEBUG_YIELD_LIB=$(builddir)/../common/libdebug-yield.la
-test_urcu_SOURCES = test_urcu.c
+test_urcu_SOURCES = test_urcu.c common-states.c
test_urcu_LDADD = $(URCU_LIB)
-test_urcu_dynamic_link_SOURCES = test_urcu.c
+test_urcu_dynamic_link_SOURCES = test_urcu.c common-states.c
test_urcu_dynamic_link_LDADD = $(URCU_LIB)
test_urcu_dynamic_link_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS)
-test_urcu_timing_SOURCES = test_urcu_timing.c
+test_urcu_timing_SOURCES = test_urcu_timing.c common-states.c
test_urcu_timing_LDADD = $(URCU_LIB)
-test_urcu_yield_SOURCES = test_urcu.c
+test_urcu_yield_SOURCES = test_urcu.c common-states.c
test_urcu_yield_LDADD = $(URCU_LIB) $(DEBUG_YIELD_LIB)
test_urcu_yield_CFLAGS = -DDEBUG_YIELD $(AM_CFLAGS)
-test_urcu_qsbr_SOURCES = test_urcu_qsbr.c
+test_urcu_qsbr_SOURCES = test_urcu_qsbr.c common-states.c
test_urcu_qsbr_LDADD = $(URCU_QSBR_LIB)
-test_urcu_qsbr_timing_SOURCES = test_urcu_qsbr_timing.c
+test_urcu_qsbr_timing_SOURCES = test_urcu_qsbr_timing.c common-states.c
test_urcu_qsbr_timing_LDADD = $(URCU_QSBR_LIB)
-test_urcu_mb_SOURCES = test_urcu.c
+test_urcu_mb_SOURCES = test_urcu.c common-states.c
test_urcu_mb_LDADD = $(URCU_MB_LIB)
test_urcu_mb_CFLAGS = -DRCU_MB $(AM_CFLAGS)
-test_urcu_signal_SOURCES = test_urcu.c
+test_urcu_signal_SOURCES = test_urcu.c common-states.c
test_urcu_signal_LDADD = $(URCU_SIGNAL_LIB)
test_urcu_signal_CFLAGS = -DRCU_SIGNAL $(AM_CFLAGS)
-test_urcu_signal_dynamic_link_SOURCES = test_urcu.c
+test_urcu_signal_dynamic_link_SOURCES = test_urcu.c common-states.c
test_urcu_signal_dynamic_link_LDADD = $(URCU_SIGNAL_LIB)
test_urcu_signal_dynamic_link_CFLAGS = -DRCU_SIGNAL -DDYNAMIC_LINK_TEST \
$(AM_CFLAGS)
-test_urcu_signal_timing_SOURCES = test_urcu_timing.c
+test_urcu_signal_timing_SOURCES = test_urcu_timing.c common-states.c
test_urcu_signal_timing_LDADD = $(URCU_SIGNAL_LIB)
test_urcu_signal_timing_CFLAGS= -DRCU_SIGNAL $(AM_CFLAGS)
-test_urcu_signal_yield_SOURCES = test_urcu.c
+test_urcu_signal_yield_SOURCES = test_urcu.c common-states.c
test_urcu_signal_yield_LDADD = $(URCU_SIGNAL_LIB) $(DEBUG_YIELD_LIB)
test_urcu_signal_yield_CFLAGS = -DRCU_SIGNAL -DDEBUG_YIELD $(AM_CFLAGS)
-test_rwlock_timing_SOURCES = test_rwlock_timing.c
+test_rwlock_timing_SOURCES = test_rwlock_timing.c common-states.c
test_rwlock_timing_LDADD = $(URCU_SIGNAL_LIB)
-test_rwlock_SOURCES = test_rwlock.c
+test_rwlock_SOURCES = test_rwlock.c common-states.c
test_rwlock_LDADD = $(URCU_SIGNAL_LIB)
-test_perthreadlock_timing_SOURCES = test_perthreadlock_timing.c
+test_perthreadlock_timing_SOURCES = test_perthreadlock_timing.c common-states.c
test_perthreadlock_timing_LDADD = $(URCU_SIGNAL_LIB)
-test_perthreadlock_SOURCES = test_perthreadlock.c
+test_perthreadlock_SOURCES = test_perthreadlock.c common-states.c
test_perthreadlock_LDADD = $(URCU_SIGNAL_LIB)
-test_mutex_SOURCES = test_mutex.c
+test_mutex_SOURCES = test_mutex.c common-states.c
-test_looplen_SOURCES = test_looplen.c
+test_looplen_SOURCES = test_looplen.c common-states.c
-test_urcu_gc_SOURCES = test_urcu_gc.c
+test_urcu_gc_SOURCES = test_urcu_gc.c common-states.c
test_urcu_gc_LDADD = $(URCU_LIB)
-test_urcu_signal_gc_SOURCES = test_urcu_gc.c
+test_urcu_signal_gc_SOURCES = test_urcu_gc.c common-states.c
test_urcu_signal_gc_LDADD = $(URCU_SIGNAL_LIB)
test_urcu_signal_gc_CFLAGS = -DRCU_SIGNAL $(AM_CFLAGS)
-test_urcu_mb_gc_SOURCES = test_urcu_gc.c
+test_urcu_mb_gc_SOURCES = test_urcu_gc.c common-states.c
test_urcu_mb_gc_LDADD = $(URCU_MB_LIB)
test_urcu_mb_gc_CFLAGS = -DRCU_MB $(AM_CFLAGS)
-test_urcu_qsbr_gc_SOURCES = test_urcu_qsbr_gc.c
+test_urcu_qsbr_gc_SOURCES = test_urcu_qsbr_gc.c common-states.c
test_urcu_qsbr_gc_LDADD = $(URCU_QSBR_LIB)
-test_urcu_qsbr_lgc_SOURCES = test_urcu_qsbr_gc.c
+test_urcu_qsbr_lgc_SOURCES = test_urcu_qsbr_gc.c common-states.c
test_urcu_qsbr_lgc_LDADD = $(URCU_QSBR_LIB)
test_urcu_qsbr_lgc_CFLAGS = -DTEST_LOCAL_GC $(AM_CFLAGS)
-test_urcu_lgc_SOURCES = test_urcu_gc.c
+test_urcu_lgc_SOURCES = test_urcu_gc.c common-states.c
test_urcu_lgc_LDADD = $(URCU_LIB)
test_urcu_lgc_CFLAGS = -DTEST_LOCAL_GC $(AM_CFLAGS)
-test_urcu_signal_lgc_SOURCES = test_urcu_gc.c
+test_urcu_signal_lgc_SOURCES = test_urcu_gc.c common-states.c
test_urcu_signal_lgc_LDADD = $(URCU_SIGNAL_LIB)
test_urcu_signal_lgc_CFLAGS = -DRCU_SIGNAL -DTEST_LOCAL_GC $(AM_CFLAGS)
-test_urcu_mb_lgc_SOURCES = test_urcu_gc.c
+test_urcu_mb_lgc_SOURCES = test_urcu_gc.c common-states.c
test_urcu_mb_lgc_LDADD = $(URCU_MB_LIB)
test_urcu_mb_lgc_CFLAGS = -DTEST_LOCAL_GC -DRCU_MB $(AM_CFLAGS)
-test_urcu_qsbr_dynamic_link_SOURCES = test_urcu_qsbr.c
+test_urcu_qsbr_dynamic_link_SOURCES = test_urcu_qsbr.c common-states.c
test_urcu_qsbr_dynamic_link_LDADD = $(URCU_QSBR_LIB)
test_urcu_qsbr_dynamic_link_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS)
-test_urcu_defer_SOURCES = test_urcu_defer.c
+test_urcu_defer_SOURCES = test_urcu_defer.c common-states.c
test_urcu_defer_LDADD = $(URCU_LIB)
test_cycles_per_loop_SOURCES = test_cycles_per_loop.c
-test_urcu_assign_SOURCES = test_urcu_assign.c
+test_urcu_assign_SOURCES = test_urcu_assign.c common-states.c
test_urcu_assign_LDADD = $(URCU_LIB)
-test_urcu_assign_dynamic_link_SOURCES = test_urcu_assign.c
+test_urcu_assign_dynamic_link_SOURCES = test_urcu_assign.c common-states.c
test_urcu_assign_dynamic_link_LDADD = $(URCU_LIB)
test_urcu_assign_dynamic_link_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS)
-test_urcu_bp_SOURCES = test_urcu_bp.c
+test_urcu_bp_SOURCES = test_urcu_bp.c common-states.c
test_urcu_bp_LDADD = $(URCU_BP_LIB)
-test_urcu_bp_dynamic_link_SOURCES = test_urcu_bp.c
+test_urcu_bp_dynamic_link_SOURCES = test_urcu_bp.c common-states.c
test_urcu_bp_dynamic_link_LDADD = $(URCU_BP_LIB)
test_urcu_bp_dynamic_link_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS)
-test_urcu_lfq_SOURCES = test_urcu_lfq.c
+test_urcu_lfq_SOURCES = test_urcu_lfq.c common-states.c
test_urcu_lfq_LDADD = $(URCU_LIB) $(URCU_CDS_LIB)
-test_urcu_lfq_dynlink_SOURCES = test_urcu_lfq.c
+test_urcu_lfq_dynlink_SOURCES = test_urcu_lfq.c common-states.c
test_urcu_lfq_dynlink_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS)
test_urcu_lfq_dynlink_LDADD = $(URCU_LIB) $(URCU_CDS_LIB)
-test_urcu_wfq_SOURCES = test_urcu_wfq.c
+test_urcu_wfq_SOURCES = test_urcu_wfq.c common-states.c
test_urcu_wfq_LDADD = $(URCU_COMMON_LIB)
-test_urcu_wfq_dynlink_SOURCES = test_urcu_wfq.c
+test_urcu_wfq_dynlink_SOURCES = test_urcu_wfq.c common-states.c
test_urcu_wfq_dynlink_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS)
test_urcu_wfq_dynlink_LDADD = $(URCU_COMMON_LIB)
-test_urcu_wfcq_SOURCES = test_urcu_wfcq.c
+test_urcu_wfcq_SOURCES = test_urcu_wfcq.c common-states.c
test_urcu_wfcq_LDADD = $(URCU_COMMON_LIB)
-test_urcu_wfcq_dynlink_SOURCES = test_urcu_wfcq.c
+test_urcu_wfcq_dynlink_SOURCES = test_urcu_wfcq.c common-states.c
test_urcu_wfcq_dynlink_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS)
test_urcu_wfcq_dynlink_LDADD = $(URCU_COMMON_LIB)
-test_urcu_lfs_SOURCES = test_urcu_lfs.c
+test_urcu_lfs_SOURCES = test_urcu_lfs.c common-states.c
test_urcu_lfs_LDADD = $(URCU_LIB) $(URCU_CDS_LIB)
-test_urcu_lfs_rcu_SOURCES = test_urcu_lfs_rcu.c
+test_urcu_lfs_rcu_SOURCES = test_urcu_lfs_rcu.c common-states.c
test_urcu_lfs_rcu_LDADD = $(URCU_LIB) $(URCU_CDS_LIB)
-test_urcu_lfs_dynlink_SOURCES = test_urcu_lfs.c
+test_urcu_lfs_dynlink_SOURCES = test_urcu_lfs.c common-states.c
test_urcu_lfs_dynlink_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS)
test_urcu_lfs_dynlink_LDADD = $(URCU_LIB) $(URCU_CDS_LIB)
-test_urcu_lfs_rcu_dynlink_SOURCES = test_urcu_lfs_rcu.c
+test_urcu_lfs_rcu_dynlink_SOURCES = test_urcu_lfs_rcu.c common-states.c
test_urcu_lfs_rcu_dynlink_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS)
test_urcu_lfs_rcu_dynlink_LDADD = $(URCU_LIB) $(URCU_CDS_LIB)
-test_urcu_wfs_SOURCES = test_urcu_wfs.c
+test_urcu_wfs_SOURCES = test_urcu_wfs.c common-states.c
test_urcu_wfs_LDADD = $(URCU_COMMON_LIB)
-test_urcu_wfs_dynlink_SOURCES = test_urcu_wfs.c
+test_urcu_wfs_dynlink_SOURCES = test_urcu_wfs.c common-states.c
test_urcu_wfs_dynlink_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS)
test_urcu_wfs_dynlink_LDADD = $(URCU_COMMON_LIB)
test_urcu_hash_SOURCES = test_urcu_hash.c test_urcu_hash.h \
- test_urcu_hash_rw.c test_urcu_hash_unique.c
+ test_urcu_hash_rw.c test_urcu_hash_unique.c common-states.c
test_urcu_hash_CFLAGS = -DRCU_QSBR $(AM_CFLAGS)
test_urcu_hash_LDADD = $(URCU_QSBR_LIB) $(URCU_COMMON_LIB) $(URCU_CDS_LIB)
--- /dev/null
+volatile int _test_go = 0, _test_stop = 0;
--- /dev/null
+/* Common states for benchmarks. */
+
+#include <unistd.h>
+
+#include <urcu/uatomic.h>
+
+extern volatile int _test_go, _test_stop;
+
+static inline void complete_sleep(unsigned int seconds)
+{
+ while (seconds != 0) {
+ seconds = sleep(seconds);
+ }
+}
+
+static inline void begin_test(void)
+{
+ uatomic_store(&_test_go, 1, CMM_RELEASE);
+}
+
+static inline void end_test(void)
+{
+ uatomic_store(&_test_stop, 1, CMM_RELAXED);
+}
+
+static inline void test_for(unsigned int duration)
+{
+ begin_test();
+ complete_sleep(duration);
+ end_test();
+}
+
+static inline void wait_until_go(void)
+{
+ while (!uatomic_load(&_test_go, CMM_ACQUIRE))
+ {
+ }
+}
+
+/*
+ * returns 0 if test should end.
+ */
+static inline int test_duration_write(void)
+{
+ return !uatomic_load(&_test_stop, CMM_RELAXED);
+}
+
+static inline int test_duration_read(void)
+{
+ return !uatomic_load(&_test_stop, CMM_RELAXED);
+}
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
-static volatile int test_go, test_stop;
-
static unsigned long wdelay;
static volatile struct test_array test_array = { 8 };
#endif /* HAVE_SCHED_SETAFFINITY */
}
-/*
- * returns 0 if test should end.
- */
-static int test_duration_write(void)
-{
- return !test_stop;
-}
-
-static int test_duration_read(void)
-{
- return !test_stop;
-}
-
static DEFINE_URCU_TLS(unsigned long long, nr_writes);
static DEFINE_URCU_TLS(unsigned long long, nr_reads);
set_affinity();
- while (!test_go)
- {
- }
+ wait_until_go();
for (;;) {
int v;
set_affinity();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
pthread_mutex_lock(&lock);
exit(1);
}
- cmm_smp_mb();
-
- test_go = 1;
-
- sleep(duration);
-
- test_stop = 1;
+ test_for(duration);
for (i_thr = 0; i_thr < nr_readers; i_thr++) {
err = pthread_join(tid_reader[i_thr], &tret);
static struct per_thread_lock *per_thread_lock;
-static volatile int test_go, test_stop;
-
static unsigned long wdelay;
static volatile struct test_array test_array = { 8 };
#endif /* HAVE_SCHED_SETAFFINITY */
}
-/*
- * returns 0 if test should end.
- */
-static int test_duration_write(void)
-{
- return !test_stop;
-}
-
-static int test_duration_read(void)
-{
- return !test_stop;
-}
-
static DEFINE_URCU_TLS(unsigned long long, nr_writes);
static DEFINE_URCU_TLS(unsigned long long, nr_reads);
set_affinity();
- while (!test_go)
- {
- }
+ wait_until_go();
for (;;) {
int v;
set_affinity();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
for (tidx = 0; tidx < (long)nr_readers; tidx++) {
exit(1);
}
- cmm_smp_mb();
-
- test_go = 1;
-
- sleep(duration);
-
- test_stop = 1;
+ test_for(duration);
for (i_thr = 0; i_thr < nr_readers; i_thr++) {
err = pthread_join(tid_reader[i_thr], &tret);
*/
pthread_rwlock_t lock;
-static volatile int test_go, test_stop;
-
static unsigned long wdelay;
static volatile struct test_array test_array = { 8 };
#endif /* HAVE_SCHED_SETAFFINITY */
}
-/*
- * returns 0 if test should end.
- */
-static int test_duration_write(void)
-{
- return !test_stop;
-}
-
-static int test_duration_read(void)
-{
- return !test_stop;
-}
-
static DEFINE_URCU_TLS(unsigned long long, nr_writes);
static DEFINE_URCU_TLS(unsigned long long, nr_reads);
set_affinity();
- while (!test_go)
- {
- }
+ wait_until_go();
for (;;) {
int a, ret;
set_affinity();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
int ret;
exit(1);
}
- cmm_smp_mb();
-
- test_go = 1;
-
- sleep(duration);
-
- test_stop = 1;
+ test_for(duration);
for (i_thr = 0; i_thr < nr_readers; i_thr++) {
err = pthread_join(tid_reader[i_thr], &tret);
#endif
#include <urcu.h>
-static volatile int test_go, test_stop;
-
static unsigned long wdelay;
static int *test_rcu_pointer;
#endif /* HAVE_SCHED_SETAFFINITY */
}
-/*
- * returns 0 if test should end.
- */
-static int test_duration_write(void)
-{
- return !test_stop;
-}
-
-static int test_duration_read(void)
-{
- return !test_stop;
-}
-
static DEFINE_URCU_TLS(unsigned long long, nr_writes);
static DEFINE_URCU_TLS(unsigned long long, nr_reads);
rcu_register_thread();
urcu_posix_assert(!rcu_read_ongoing());
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
rcu_read_lock();
set_affinity();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
new = malloc(sizeof(int));
exit(1);
}
- cmm_smp_mb();
-
- test_go = 1;
-
- sleep(duration);
-
- test_stop = 1;
+ test_for(duration);
for (i_thr = 0; i_thr < nr_readers; i_thr++) {
err = pthread_join(tid_reader[i_thr], &tret);
int a;
};
-static volatile int test_go, test_stop;
-
static unsigned long wdelay;
static struct test_array *test_rcu_pointer;
#endif /* HAVE_SCHED_SETAFFINITY */
}
-/*
- * returns 0 if test should end.
- */
-static int test_duration_write(void)
-{
- return !test_stop;
-}
-
-static int test_duration_read(void)
-{
- return !test_stop;
-}
-
static DEFINE_URCU_TLS(unsigned long long, nr_writes);
static DEFINE_URCU_TLS(unsigned long long, nr_reads);
rcu_register_thread();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
rcu_read_lock();
set_affinity();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
rcu_copy_mutex_lock();
exit(1);
}
- cmm_smp_mb();
-
- test_go = 1;
-
- sleep(duration);
-
- test_stop = 1;
+ test_for(duration);
for (i_thr = 0; i_thr < nr_readers; i_thr++) {
err = pthread_join(tid_reader[i_thr], &tret);
#endif
#include <urcu-bp.h>
-static volatile int test_go, test_stop;
-
static unsigned long wdelay;
static int *test_rcu_pointer;
#endif /* HAVE_SCHED_SETAFFINITY */
}
-/*
- * returns 0 if test should end.
- */
-static int test_duration_write(void)
-{
- return !test_stop;
-}
-
-static int test_duration_read(void)
-{
- return !test_stop;
-}
-
static DEFINE_URCU_TLS(unsigned long long, nr_writes);
static DEFINE_URCU_TLS(unsigned long long, nr_reads);
rcu_register_thread();
urcu_posix_assert(!rcu_read_ongoing());
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
rcu_read_lock();
set_affinity();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
new = malloc(sizeof(int));
exit(1);
}
- cmm_smp_mb();
-
- test_go = 1;
-
- sleep(duration);
-
- test_stop = 1;
+ test_for(duration);
for (i_thr = 0; i_thr < nr_readers; i_thr++) {
err = pthread_join(tid_reader[i_thr], &tret);
int a;
};
-static volatile int test_go, test_stop;
-
static unsigned long wdelay;
static struct test_array *test_rcu_pointer;
#endif /* HAVE_SCHED_SETAFFINITY */
}
-/*
- * returns 0 if test should end.
- */
-static int test_duration_write(void)
-{
- return !test_stop;
-}
-
-static int test_duration_read(void)
-{
- return !test_stop;
-}
-
static DEFINE_URCU_TLS(unsigned long long, nr_writes);
static DEFINE_URCU_TLS(unsigned long long, nr_reads);
rcu_register_thread();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
rcu_read_lock();
exit(-1);
}
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
new = malloc(sizeof(*new));
exit(1);
}
- cmm_smp_mb();
-
- test_go = 1;
-
- sleep(duration);
-
- test_stop = 1;
+ test_for(duration);
for (i_thr = 0; i_thr < nr_readers; i_thr++) {
err = pthread_join(tid_reader[i_thr], &tret);
#include <urcu/arch.h>
#include <urcu/assert.h>
#include <urcu/tls-compat.h>
+#include <urcu/uatomic.h>
#include "thread-id.h"
#include "../common/debug-yield.h"
int a;
};
-static volatile int test_go, test_stop;
-
static unsigned long wdelay;
static struct test_array *test_rcu_pointer;
#endif /* HAVE_SCHED_SETAFFINITY */
}
-/*
- * returns 0 if test should end.
- */
-static int test_duration_write(void)
-{
- return !test_stop;
-}
-
-static int test_duration_read(void)
-{
- return !test_stop;
-}
-
static DEFINE_URCU_TLS(unsigned long long, nr_writes);
static DEFINE_URCU_TLS(unsigned long long, nr_reads);
rcu_register_thread();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
rcu_read_lock();
set_affinity();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
#ifndef TEST_LOCAL_GC
exit(1);
}
- cmm_smp_mb();
-
- test_go = 1;
-
- sleep(duration);
-
- test_stop = 1;
+ test_for(duration);
for (i_thr = 0; i_thr < nr_readers; i_thr++) {
err = pthread_join(tid_reader[i_thr], &tret);
struct cds_lfht *test_ht;
-volatile int test_go, test_stop;
-
unsigned long wdelay;
unsigned long duration;
cmm_smp_mb();
- test_go = 1;
+ begin_test();
remain = duration;
do {
remain = sleep(remain);
} while (remain > 0);
- test_stop = 1;
+ end_test();
end_pthread_join:
for (i_thr = 0; i_thr < nr_readers_created; i_thr++) {
return to_test_node(cds_lfht_iter_get_node(iter));
}
-extern volatile int test_go, test_stop;
-
extern unsigned long wdelay;
extern unsigned long duration;
void set_affinity(void);
-/*
- * returns 0 if test should end.
- */
-static inline int test_duration_write(void)
-{
- return !test_stop;
-}
-
-static inline int test_duration_read(void)
-{
- return !test_stop;
-}
-
extern DECLARE_URCU_TLS(unsigned long long, nr_writes);
extern DECLARE_URCU_TLS(unsigned long long, nr_reads);
rcu_register_thread();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
rcu_read_lock();
rcu_register_thread();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
struct cds_lfht_node *ret_node = NULL;
rcu_register_thread();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
struct lfht_test_node *node;
rcu_register_thread();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
/*
#include <urcu.h>
#include <urcu/cds.h>
-static volatile int test_go, test_stop;
-
static unsigned long rduration;
static unsigned long duration;
*/
static int test_duration_dequeue(void)
{
- return !test_stop;
+ return test_duration_read();
}
static int test_duration_enqueue(void)
{
- return !test_stop;
+ return test_duration_write();
}
static DEFINE_URCU_TLS(unsigned long long, nr_dequeues);
rcu_register_thread();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
struct test *node = malloc(sizeof(*node));
rcu_register_thread();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
struct cds_lfq_node_rcu *qnode;
cmm_smp_mb();
- test_go = 1;
+ begin_test();
for (i_thr = 0; i_thr < duration; i_thr++) {
sleep(1);
}
}
- test_stop = 1;
+ end_test();
for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) {
err = pthread_join(tid_enqueuer[i_thr], &tret);
static enum test_sync test_sync;
-static volatile int test_go, test_stop;
-
static unsigned long rduration;
static unsigned long duration;
*/
static int test_duration_dequeue(void)
{
- return !test_stop;
+ return test_duration_read();
}
static int test_duration_enqueue(void)
{
- return !test_stop;
+ return test_duration_write();
}
static DEFINE_URCU_TLS(unsigned long long, nr_dequeues);
rcu_register_thread();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
struct test *node = malloc(sizeof(*node));
rcu_register_thread();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
urcu_posix_assert(test_pop || test_pop_all);
cmm_smp_mb();
- test_go = 1;
+ begin_test();
for (i_thr = 0; i_thr < duration; i_thr++) {
sleep(1);
}
}
- test_stop = 1;
+ end_test();
for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) {
err = pthread_join(tid_enqueuer[i_thr], &tret);
#include <urcu/cds.h>
-static volatile int test_go, test_stop;
-
static unsigned long rduration;
static unsigned long duration;
*/
static int test_duration_dequeue(void)
{
- return !test_stop;
+ return test_duration_read();
}
static int test_duration_enqueue(void)
{
- return !test_stop;
+ return test_duration_write();
}
static DEFINE_URCU_TLS(unsigned long long, nr_dequeues);
rcu_register_thread();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
struct test *node = malloc(sizeof(*node));
rcu_register_thread();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
struct cds_lfs_node_rcu *snode;
cmm_smp_mb();
- test_go = 1;
+ begin_test();
for (i_thr = 0; i_thr < duration; i_thr++) {
sleep(1);
}
}
- test_stop = 1;
+ end_test();
for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) {
err = pthread_join(tid_enqueuer[i_thr], &tret);
#endif
#include "urcu-qsbr.h"
-static volatile int test_go, test_stop;
-
static unsigned long wdelay;
static int *test_rcu_pointer;
#endif /* HAVE_SCHED_SETAFFINITY */
}
-/*
- * returns 0 if test should end.
- */
-static int test_duration_write(void)
-{
- return !test_stop;
-}
-
-static int test_duration_read(void)
-{
- return !test_stop;
-}
-
static DEFINE_URCU_TLS(unsigned long long, nr_writes);
static DEFINE_URCU_TLS(unsigned long long, nr_reads);
urcu_posix_assert(!rcu_read_ongoing());
rcu_thread_online();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
rcu_read_lock();
set_affinity();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
new = malloc(sizeof(int));
exit(1);
}
- cmm_smp_mb();
-
- test_go = 1;
-
- sleep(duration);
-
- test_stop = 1;
+ test_for(duration);
for (i_thr = 0; i_thr < nr_readers; i_thr++) {
err = pthread_join(tid_reader[i_thr], &tret);
#include <urcu/arch.h>
#include <urcu/assert.h>
#include <urcu/tls-compat.h>
+#include <urcu/uatomic.h>
#include "thread-id.h"
#include "../common/debug-yield.h"
int a;
};
-static volatile int test_go, test_stop;
-
static unsigned long wdelay;
static struct test_array *test_rcu_pointer;
#endif /* HAVE_SCHED_SETAFFINITY */
}
-/*
- * returns 0 if test should end.
- */
-static int test_duration_write(void)
-{
- return !test_stop;
-}
-
-static int test_duration_read(void)
-{
- return !test_stop;
-}
-
static DEFINE_URCU_TLS(unsigned long long, nr_writes);
static DEFINE_URCU_TLS(unsigned long long, nr_reads);
rcu_register_thread();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
_rcu_read_lock();
set_affinity();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
#ifndef TEST_LOCAL_GC
exit(1);
}
- cmm_smp_mb();
-
- test_go = 1;
-
- sleep(duration);
-
- test_stop = 1;
+ test_for(duration);
for (i_thr = 0; i_thr < nr_readers; i_thr++) {
err = pthread_join(tid_reader[i_thr], &tret);
static int test_force_sync;
-static volatile int test_go, test_stop_enqueue, test_stop_dequeue;
+static volatile int test_stop_enqueue, test_stop_dequeue;
static unsigned long rduration;
*/
static int test_duration_dequeue(void)
{
- return !test_stop_dequeue;
+ return !uatomic_load(&test_stop_dequeue, CMM_RELAXED);
}
static int test_duration_enqueue(void)
{
- return !test_stop_enqueue;
+ return !uatomic_load(&test_stop_enqueue, CMM_RELAXED);
}
static DEFINE_URCU_TLS(unsigned long long, nr_dequeues);
set_affinity();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
struct cds_wfcq_node *node = malloc(sizeof(*node));
set_affinity();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
if (test_dequeue && test_splice) {
cmm_smp_mb();
- test_go = 1;
+ begin_test();
for (i_thr = 0; i_thr < duration; i_thr++) {
sleep(1);
}
}
- test_stop_enqueue = 1;
+ uatomic_store(&test_stop_enqueue, 1, CMM_RELEASE);
if (test_wait_empty) {
while (nr_enqueuers != uatomic_read(&test_enqueue_stopped)) {
}
}
- test_stop_dequeue = 1;
+ uatomic_store(&test_stop_dequeue, 1, CMM_RELAXED);
for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) {
err = pthread_join(tid_enqueuer[i_thr], &tret);
#include <urcu.h>
#include <urcu/wfqueue.h>
-static volatile int test_go, test_stop;
-
static unsigned long rduration;
static unsigned long duration;
*/
static int test_duration_dequeue(void)
{
- return !test_stop;
+ return test_duration_read();
}
static int test_duration_enqueue(void)
{
- return !test_stop;
+ return test_duration_write();
}
static DEFINE_URCU_TLS(unsigned long long, nr_dequeues);
set_affinity();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
struct cds_wfq_node *node = malloc(sizeof(*node));
set_affinity();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
struct cds_wfq_node *node = cds_wfq_dequeue_blocking(&q);
cmm_smp_mb();
- test_go = 1;
+ begin_test();
for (i_thr = 0; i_thr < duration; i_thr++) {
sleep(1);
}
}
- test_stop = 1;
+ end_test();
for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) {
err = pthread_join(tid_enqueuer[i_thr], &tret);
static int test_force_sync;
-static volatile int test_go, test_stop_enqueue, test_stop_dequeue;
+static volatile int test_stop_enqueue, test_stop_dequeue;
static unsigned long rduration;
*/
static int test_duration_dequeue(void)
{
- return !test_stop_dequeue;
+ return !uatomic_load(&test_stop_dequeue, CMM_RELAXED);
}
static int test_duration_enqueue(void)
{
- return !test_stop_enqueue;
+ return !uatomic_load(&test_stop_enqueue, CMM_RELAXED);
}
static DEFINE_URCU_TLS(unsigned long long, nr_dequeues);
set_affinity();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
for (;;) {
struct cds_wfs_node *node = malloc(sizeof(*node));
set_affinity();
- while (!test_go)
- {
- }
- cmm_smp_mb();
+ wait_until_go();
urcu_posix_assert(test_pop || test_pop_all);
cmm_smp_mb();
- test_go = 1;
+ begin_test();
for (i_thr = 0; i_thr < duration; i_thr++) {
sleep(1);
}
}
- test_stop_enqueue = 1;
+ uatomic_store(&test_stop_enqueue, 1, CMM_RELEASE);
if (test_wait_empty) {
while (nr_enqueuers != uatomic_read(&test_enqueue_stopped)) {
}
}
- test_stop_dequeue = 1;
+ uatomic_store(&test_stop_dequeue, 1, CMM_RELAXED);
for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) {
err = pthread_join(tid_enqueuer[i_thr], &tret);