summaryrefslogtreecommitdiff
path: root/tests/barrier5.c
diff options
context:
space:
mode:
authorrpj <rpj>2001-07-11 17:02:27 +0000
committerrpj <rpj>2001-07-11 17:02:27 +0000
commita6b214d1eb218ec6a9d78abeaa483fbf6f485aad (patch)
treec39a63cee6d8e2fba4f1e2077527598d9239917c /tests/barrier5.c
parentd330ac695b57dbcf32ac455c89e72a3a8f8bb956 (diff)
Assert that exactly one thread receives PTHREAD_BARRIER_SERIAL_THREAD.snap-2001-07-12
Diffstat (limited to 'tests/barrier5.c')
-rw-r--r--tests/barrier5.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/tests/barrier5.c b/tests/barrier5.c
index 77f51da..00ad616 100644
--- a/tests/barrier5.c
+++ b/tests/barrier5.c
@@ -23,6 +23,7 @@ func(void * barrierHeight)
{
int i;
int result;
+ int serialThreads = 0;
for (i = 1; i < BARRIERS; i++)
{
@@ -38,6 +39,7 @@ func(void * barrierHeight)
*/
if (result == PTHREAD_BARRIER_SERIAL_THREAD)
{
+ serialThreads++;
assert(barrierReleases[i - 1] == (int) barrierHeight);
barrierReleases[i + 1] = 0;
}
@@ -49,13 +51,15 @@ func(void * barrierHeight)
}
}
- return NULL;
+ return (void *) serialThreads;
}
int
main()
{
int i, j;
+ int result;
+ int serialThreadsTotal;
pthread_t t[NUMTHREADS + 1];
for (j = 1; j <= NUMTHREADS; j++)
@@ -72,11 +76,14 @@ main()
assert(pthread_create(&t[i], NULL, func, (void *) j) == 0);
}
+ serialThreadsTotal = 0;
for (i = 1; i <= j; i++)
{
- assert(pthread_join(t[i], NULL) == 0);
+ assert(pthread_join(t[i], (void **) &result) == 0);
+ serialThreadsTotal += result;
}
+ assert(serialThreadsTotal == BARRIERS - 1);
assert(barrierReleases[BARRIERS - 1] == j);
assert(barrierReleases[BARRIERS] == 0);