From 551e2b2bf8052d2ae3901c5ed2860831a86a3770 Mon Sep 17 00:00:00 2001 From: Daniel Bittman Date: Mon, 2 May 2016 16:27:08 -0700 Subject: [PATCH] Fix testing bug. --- mpsc_test.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mpsc_test.c b/mpsc_test.c index 7bf2a03..2781122 100644 --- a/mpsc_test.c +++ b/mpsc_test.c @@ -20,11 +20,11 @@ struct item { _Atomic int sent, recv; }; -struct item items[NUM_THREADS][NUM_ITEMS]; +_Atomic struct item items[NUM_THREADS][NUM_ITEMS]; void *producer_main(void *x) { - int tid = (int)x; + long tid = (long)x; struct timespec start, end; for(int i=0;isent, 1) == 1); assert(atomic_fetch_add(&it->recv, 1) == 0); - } - if(!ret && done) { - if(!mpscq_dequeue(queue)) - break; - else - atomic_fetch_add(&amount_consumed, 1); + doublechecked = false; + } else if(done && doublechecked) { + break; + } else if(done) { + doublechecked = true; } } assert(!mpscq_dequeue(queue)); @@ -111,8 +111,8 @@ int main(int argc, char **argv) for(int i=0;i