TESTS+=" dekker-fences/dekker-fences"
TESTS+=" mpmc-queue/mpmc-2r1w"
TESTS+=" mpmc-queue/mpmc-1r2w-noinit"
+TESTS+=" mpmc-queue/mpmc-queue-rdwr"
+TESTS+=" mpmc-queue/mpmc-rdwr-noinit"
TESTS+=" mpmc-queue/mpmc-queue-noinit"
TESTS+=" linuxrwlocks/linuxrwlocks"
include ../benchmarks.mk
TESTNAME = mpmc-queue
-TESTS = mpmc-queue mpmc-1r2w mpmc-2r1w
-TESTS += mpmc-queue-noinit mpmc-1r2w-noinit mpmc-2r1w-noinit
+TESTS = mpmc-queue mpmc-1r2w mpmc-2r1w mpmc-queue-rdwr
+TESTS += mpmc-queue-noinit mpmc-1r2w-noinit mpmc-2r1w-noinit mpmc-rdwr-noinit
all: $(TESTS)
mpmc-queue: CPPFLAGS += -DCONFIG_MPMC_READERS=2 -DCONFIG_MPMC_WRITERS=2
+mpmc-queue-rdwr: CPPFLAGS += -DCONFIG_MPMC_READERS=0 -DCONFIG_MPMC_WRITERS=0 -DCONFIG_MPMC_RDWR=2
mpmc-1r2w: CPPFLAGS += -DCONFIG_MPMC_READERS=1 -DCONFIG_MPMC_WRITERS=2
mpmc-2r1w: CPPFLAGS += -DCONFIG_MPMC_READERS=2 -DCONFIG_MPMC_WRITERS=1
mpmc-queue-noinit: CPPFLAGS += -DCONFIG_MPMC_READERS=2 -DCONFIG_MPMC_WRITERS=2 -DCONFIG_MPMC_NO_INITIAL_ELEMENT
mpmc-1r2w-noinit: CPPFLAGS += -DCONFIG_MPMC_READERS=1 -DCONFIG_MPMC_WRITERS=2 -DCONFIG_MPMC_NO_INITIAL_ELEMENT
mpmc-2r1w-noinit: CPPFLAGS += -DCONFIG_MPMC_READERS=2 -DCONFIG_MPMC_WRITERS=1 -DCONFIG_MPMC_NO_INITIAL_ELEMENT
+mpmc-rdwr-noinit: CPPFLAGS += -DCONFIG_MPMC_READERS=0 -DCONFIG_MPMC_WRITERS=0 -DCONFIG_MPMC_RDWR=2 -DCONFIG_MPMC_NO_INITIAL_ELEMENT
$(TESTS): $(TESTNAME).cc $(TESTNAME).h
$(CXX) -o $@ $< $(CPPFLAGS) $(LDFLAGS)
}
}
+void threadC(struct mpmc_boundq_1_alt<int32_t, sizeof(int32_t)> *queue)
+{
+ int32_t *bin = queue->write_prepare();
+ store_32(bin, 1);
+ queue->write_publish();
+
+ while (bin = queue->read_fetch()) {
+ printf("Read: %d\n", load_32(bin));
+ queue->read_consume();
+ }
+}
+
#define MAXREADERS 3
#define MAXWRITERS 3
+#define MAXRDWR 3
#ifdef CONFIG_MPMC_READERS
#define DEFAULT_READERS (CONFIG_MPMC_READERS)
#define DEFAULT_WRITERS 2
#endif
-int readers = DEFAULT_READERS, writers = DEFAULT_WRITERS;
+#ifdef CONFIG_MPMC_RDWR
+#define DEFAULT_RDWR (CONFIG_MPMC_RDWR)
+#else
+#define DEFAULT_RDWR 0
+#endif
+
+int readers = DEFAULT_READERS, writers = DEFAULT_WRITERS, rdwr = DEFAULT_RDWR;
void print_usage()
{
int user_main(int argc, char **argv)
{
struct mpmc_boundq_1_alt<int32_t, sizeof(int32_t)> queue;
- thrd_t A[MAXWRITERS], B[MAXREADERS];
+ thrd_t A[MAXWRITERS], B[MAXREADERS], C[MAXRDWR];
/* Note: optarg() / optind is broken in model-checker - workaround is
* to just copy&paste this test a few times */
for (int i = 0; i < readers; i++)
thrd_create(&B[i], (thrd_start_t)&threadB, &queue);
+ for (int i = 0; i < rdwr; i++)
+ thrd_create(&C[i], (thrd_start_t)&threadC, &queue);
+
for (int i = 0; i < writers; i++)
thrd_join(A[i]);
for (int i = 0; i < readers; i++)
thrd_join(B[i]);
+ for (int i = 0; i < rdwr; i++)
+ thrd_join(C[i]);
printf("Threads complete\n");