|
|
@@ -27,10 +27,10 @@ static DWORD WINAPI test_synch_barrier_thread(LPVOID lpParam)
|
|
|
BOOL status = FALSE;
|
|
|
struct test_params* p = (struct test_params*)lpParam;
|
|
|
DWORD i;
|
|
|
-
|
|
|
+ const ULONG currentNum = p->threadCount + 1;
|
|
|
InterlockedIncrement(&p->threadCount);
|
|
|
|
|
|
- // printf("Thread #%03u entered.\n", tnum);
|
|
|
+ printf("Thread #%03u entered.\n", currentNum);
|
|
|
|
|
|
/* wait for start event from main */
|
|
|
if (WaitForSingleObject(gStartEvent, INFINITE) != WAIT_OBJECT_0)
|
|
|
@@ -39,7 +39,7 @@ static DWORD WINAPI test_synch_barrier_thread(LPVOID lpParam)
|
|
|
goto out;
|
|
|
}
|
|
|
|
|
|
- // printf("Thread #%03u unblocked.\n", tnum);
|
|
|
+ printf("Thread #%03u unblocked.\n", currentNum);
|
|
|
|
|
|
for (i = 0; i < p->loops && gErrorCount == 0; i++)
|
|
|
{
|
|
|
@@ -47,7 +47,7 @@ static DWORD WINAPI test_synch_barrier_thread(LPVOID lpParam)
|
|
|
Sleep(rand() % MAX_SLEEP_MS);
|
|
|
status = EnterSynchronizationBarrier(&gBarrier, p->flags);
|
|
|
|
|
|
- // printf("Thread #%03u status: %s\n", tnum, status ? "TRUE" : "FALSE");
|
|
|
+ printf("Thread #%03u status: %s\n", currentNum, status ? "TRUE" : "FALSE");
|
|
|
if (status)
|
|
|
InterlockedIncrement(&p->trueCount);
|
|
|
else
|
|
|
@@ -55,7 +55,7 @@ static DWORD WINAPI test_synch_barrier_thread(LPVOID lpParam)
|
|
|
}
|
|
|
|
|
|
out:
|
|
|
- // printf("Thread #%03u leaving.\n", tnum);
|
|
|
+ printf("Thread #%03u leaving.\n", currentNum);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
@@ -121,6 +121,7 @@ static BOOL TestSynchBarrierWithFlags(DWORD dwFlags, DWORD dwThreads, DWORD dwLo
|
|
|
|
|
|
while (i--)
|
|
|
{
|
|
|
+ printf("%s: WaitForSingleObject(thread[%" PRIu32 "])...\n", __FUNCTION__, i);
|
|
|
if (WAIT_OBJECT_0 != (dwStatus = WaitForSingleObject(threads[i], INFINITE)))
|
|
|
{
|
|
|
printf("%s: WaitForSingleObject(thread[%" PRIu32 "] unexpectedly returned %" PRIu32
|
|
|
@@ -198,6 +199,7 @@ int TestSynchBarrier(int argc, char* argv[])
|
|
|
__FUNCTION__);
|
|
|
return -1;
|
|
|
}
|
|
|
+ printf("%s: InitializeSynchronizationBarrier succeeded with lTotalThreads = 0\n",__FUNCTION__);
|
|
|
|
|
|
if (InitializeSynchronizationBarrier(&gBarrier, -1, -1))
|
|
|
{
|
|
|
@@ -206,6 +208,8 @@ int TestSynchBarrier(int argc, char* argv[])
|
|
|
__FUNCTION__);
|
|
|
return -1;
|
|
|
}
|
|
|
+ printf("%s: InitializeSynchronizationBarrier succeeded with lTotalThreads = -1\n",__FUNCTION__);
|
|
|
+
|
|
|
|
|
|
if (InitializeSynchronizationBarrier(&gBarrier, 1, -2))
|
|
|
{
|
|
|
@@ -213,16 +217,20 @@ int TestSynchBarrier(int argc, char* argv[])
|
|
|
__FUNCTION__);
|
|
|
return -1;
|
|
|
}
|
|
|
+ printf("%s: InitializeSynchronizationBarrier succeeded with lSpinCount = -2\n", __FUNCTION__);
|
|
|
|
|
|
/* Functional tests */
|
|
|
|
|
|
+ printf("%s: test TestSynchBarrierWithFlags\n", __FUNCTION__);
|
|
|
if (!TestSynchBarrierWithFlags(0, dwMaxThreads, dwNumLoops))
|
|
|
return -1;
|
|
|
|
|
|
+ printf("%s: test TestSynchBarrierWithFlags with SYNCHRONIZATION_BARRIER_FLAGS_SPIN_ONLY\n", __FUNCTION__);
|
|
|
if (!TestSynchBarrierWithFlags(SYNCHRONIZATION_BARRIER_FLAGS_SPIN_ONLY, dwMinThreads,
|
|
|
dwNumLoops))
|
|
|
return -1;
|
|
|
|
|
|
+ printf("%s: test TestSynchBarrierWithFlags with SYNCHRONIZATION_BARRIER_FLAGS_BLOCK_ONLY\n", __FUNCTION__);
|
|
|
if (!TestSynchBarrierWithFlags(SYNCHRONIZATION_BARRIER_FLAGS_BLOCK_ONLY, dwMaxThreads,
|
|
|
dwNumLoops))
|
|
|
return -1;
|