```--- 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 {
-  BARRIERS = 10000
+  HEIGHT = 10,
+  BARRIERMULTIPLE = 1000
};

-
-int barrierReleases[BARRIERS + 1];

void *
-func(void * barrierHeight)
+func(void * crossings)
{
-  int i;
int result;

-  for (i = 1; i < BARRIERS; i++)
{

-      barrierReleases[i]++;
-      /*
-       * 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.
-       */
{
-          assert(barrierReleases[i - 1] == (int) barrierHeight);
-          barrierReleases[i + 1] = 0;
}
else if (result != 0)
{
@@ -92,20 +81,23 @@
int i, j;
int result;
+  LONG Crossings;

for (j = 1; j <= NUMTHREADS; j++)
{
-      printf("Barrier height = %d\n", j);
+      int height = j<HEIGHT?j:HEIGHT;

-      barrierReleases[0] = j;
-      barrierReleases[1] = 0;
+      Crossings = height * BARRIERMULTIPLE;

-      assert(pthread_barrier_init(&barrier, NULL, j) == 0);
+      printf("Threads=%d, Barrier height=%d\n", j, height);
+
+      assert(pthread_barrier_init(&barrier, NULL, height) == 0);

for (i = 1; i <= j; i++)
{
-          assert(pthread_create(&t[i], NULL, func, (void *) j) == 0);
+          assert(pthread_create(&t[i], NULL, func, (void *) Crossings) == 0);
}