From a3ea0b24409b89bd08c0a2268dbae834724734df Mon Sep 17 00:00:00 2001 From: rpj Date: Sun, 20 Jun 2010 03:31:18 +0000 Subject: See ChangeLogs: preparing for new release. --- tests/barrier5.c | 46 ++++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 28 deletions(-) (limited to 'tests/barrier5.c') diff --git a/tests/barrier5.c b/tests/barrier5.c index 5b598c9..851398c 100644 --- a/tests/barrier5.c +++ b/tests/barrier5.c @@ -33,47 +33,36 @@ * * -------------------------------------------------------------------------- * - * Declare a single barrier object, set up a sequence of - * barrier points to prove lockstepness, and then destroy it. - * + * Set up a series of barriers at different heights and test various numbers + * of threads accessing, especially cases where there are more threads than the + * barrier height (count), i.e. test contention when the barrier is released. */ #include "test.h" enum { - NUMTHREADS = 16, - BARRIERS = 10000 + NUMTHREADS = 15, + HEIGHT = 10, + BARRIERMULTIPLE = 1000 }; pthread_barrier_t barrier = NULL; pthread_mutex_t mx = PTHREAD_MUTEX_INITIALIZER; - -int barrierReleases[BARRIERS + 1]; +LONG totalThreadCrossings; void * -func(void * barrierHeight) +func(void * crossings) { - int i; int result; int serialThreads = 0; - for (i = 1; i < BARRIERS; i++) + while ((LONG)crossings >= (LONG)InterlockedIncrement((LPLONG)&totalThreadCrossings)) { result = pthread_barrier_wait(&barrier); - assert(pthread_mutex_lock(&mx) == 0); - barrierReleases[i]++; - assert(pthread_mutex_unlock(&mx) == 0); - /* - * Confirm the correct number of releases from the previous - * barrier. We can't do the current barrier yet because there may - * still be threads waking up. - */ if (result == PTHREAD_BARRIER_SERIAL_THREAD) { serialThreads++; - assert(barrierReleases[i - 1] == (int) barrierHeight); - barrierReleases[i + 1] = 0; } else if (result != 0) { @@ -92,20 +81,23 @@ main() int i, j; int result; int serialThreadsTotal; + LONG Crossings; pthread_t t[NUMTHREADS + 1]; for (j = 1; j <= NUMTHREADS; j++) { - printf("Barrier height = %d\n", j); + int height = j