8e937899612528c862aad84d39ca073d231c3057vboxsync/* $Id$ */
8e937899612528c862aad84d39ca073d231c3057vboxsync/** @file
7b3d8a8298d217445c72a3afaf7cc2e07f6d7d74vboxsync * IPRT Testcase - Simple Mutex Semaphore Smoke Test.
8e937899612528c862aad84d39ca073d231c3057vboxsync */
8e937899612528c862aad84d39ca073d231c3057vboxsync
8e937899612528c862aad84d39ca073d231c3057vboxsync/*
c58f1213e628a545081c70e26c6b67a841cff880vboxsync * Copyright (C) 2006-2011 Oracle Corporation
8e937899612528c862aad84d39ca073d231c3057vboxsync *
8e937899612528c862aad84d39ca073d231c3057vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
8e937899612528c862aad84d39ca073d231c3057vboxsync * available from http://www.virtualbox.org. This file is free software;
8e937899612528c862aad84d39ca073d231c3057vboxsync * you can redistribute it and/or modify it under the terms of the GNU
8e937899612528c862aad84d39ca073d231c3057vboxsync * General Public License (GPL) as published by the Free Software
8e937899612528c862aad84d39ca073d231c3057vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
8e937899612528c862aad84d39ca073d231c3057vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
8e937899612528c862aad84d39ca073d231c3057vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
8e937899612528c862aad84d39ca073d231c3057vboxsync *
8e937899612528c862aad84d39ca073d231c3057vboxsync * The contents of this file may alternatively be used under the terms
8e937899612528c862aad84d39ca073d231c3057vboxsync * of the Common Development and Distribution License Version 1.0
8e937899612528c862aad84d39ca073d231c3057vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
8e937899612528c862aad84d39ca073d231c3057vboxsync * VirtualBox OSE distribution, in which case the provisions of the
8e937899612528c862aad84d39ca073d231c3057vboxsync * CDDL are applicable instead of those of the GPL.
8e937899612528c862aad84d39ca073d231c3057vboxsync *
8e937899612528c862aad84d39ca073d231c3057vboxsync * You may elect to license modified versions of this file under the
8e937899612528c862aad84d39ca073d231c3057vboxsync * terms and conditions of either the GPL or the CDDL or both.
8e937899612528c862aad84d39ca073d231c3057vboxsync */
8e937899612528c862aad84d39ca073d231c3057vboxsync
8e937899612528c862aad84d39ca073d231c3057vboxsync/*******************************************************************************
8e937899612528c862aad84d39ca073d231c3057vboxsync* Header Files *
8e937899612528c862aad84d39ca073d231c3057vboxsync*******************************************************************************/
8e937899612528c862aad84d39ca073d231c3057vboxsync#include <iprt/semaphore.h>
8e937899612528c862aad84d39ca073d231c3057vboxsync#include <iprt/string.h>
8e937899612528c862aad84d39ca073d231c3057vboxsync#include <iprt/thread.h>
8e937899612528c862aad84d39ca073d231c3057vboxsync#include <iprt/stream.h>
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync#include <iprt/time.h>
8e937899612528c862aad84d39ca073d231c3057vboxsync#include <iprt/initterm.h>
8e937899612528c862aad84d39ca073d231c3057vboxsync#include <iprt/asm.h>
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync#include <iprt/assert.h>
8e937899612528c862aad84d39ca073d231c3057vboxsync
8e937899612528c862aad84d39ca073d231c3057vboxsync
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync/*******************************************************************************
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync* Global Variables *
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync*******************************************************************************/
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsyncstatic RTSEMMUTEX g_hMutex = NIL_RTSEMMUTEX;
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsyncstatic bool volatile g_fTerminate;
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsyncstatic bool g_fYield;
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsyncstatic bool g_fQuiet;
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsyncstatic uint32_t volatile g_cbConcurrent;
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsyncstatic uint32_t volatile g_cErrors;
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsyncint PrintError(const char *pszFormat, ...)
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync{
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync ASMAtomicIncU32(&g_cErrors);
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync RTPrintf("tstSemMutex: FAILURE - ");
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync va_list va;
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync va_start(va, pszFormat);
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync RTPrintfV(pszFormat, va);
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync va_end(va);
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync return 1;
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync}
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync
8e937899612528c862aad84d39ca073d231c3057vboxsync
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsyncint ThreadTest1(RTTHREAD ThreadSelf, void *pvUser)
8e937899612528c862aad84d39ca073d231c3057vboxsync{
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync uint64_t *pu64 = (uint64_t *)pvUser;
8e937899612528c862aad84d39ca073d231c3057vboxsync for (;;)
8e937899612528c862aad84d39ca073d231c3057vboxsync {
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync int rc = RTSemMutexRequestNoResume(g_hMutex, RT_INDEFINITE_WAIT);
8e937899612528c862aad84d39ca073d231c3057vboxsync if (RT_FAILURE(rc))
8e937899612528c862aad84d39ca073d231c3057vboxsync {
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync PrintError("%x: RTSemMutexRequestNoResume failed with %Rrc\n", rc);
8e937899612528c862aad84d39ca073d231c3057vboxsync break;
8e937899612528c862aad84d39ca073d231c3057vboxsync }
8e937899612528c862aad84d39ca073d231c3057vboxsync if (ASMAtomicIncU32(&g_cbConcurrent) != 1)
8e937899612528c862aad84d39ca073d231c3057vboxsync {
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync PrintError("g_cbConcurrent=%d after request!\n", g_cbConcurrent);
8e937899612528c862aad84d39ca073d231c3057vboxsync break;
8e937899612528c862aad84d39ca073d231c3057vboxsync }
8e937899612528c862aad84d39ca073d231c3057vboxsync
8e937899612528c862aad84d39ca073d231c3057vboxsync /*
8e937899612528c862aad84d39ca073d231c3057vboxsync * Check for fairness: The values of the threads should not differ too much
8e937899612528c862aad84d39ca073d231c3057vboxsync */
8e937899612528c862aad84d39ca073d231c3057vboxsync (*pu64)++;
8e937899612528c862aad84d39ca073d231c3057vboxsync
8e937899612528c862aad84d39ca073d231c3057vboxsync /*
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync * Check for correctness: Give other threads a chance. If the implementation is
8e937899612528c862aad84d39ca073d231c3057vboxsync * correct, no other thread will be able to enter this lock now.
8e937899612528c862aad84d39ca073d231c3057vboxsync */
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync if (g_fYield)
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync RTThreadYield();
8e937899612528c862aad84d39ca073d231c3057vboxsync if (ASMAtomicDecU32(&g_cbConcurrent) != 0)
8e937899612528c862aad84d39ca073d231c3057vboxsync {
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync PrintError("g_cbConcurrent=%d before release!\n", g_cbConcurrent);
8e937899612528c862aad84d39ca073d231c3057vboxsync break;
8e937899612528c862aad84d39ca073d231c3057vboxsync }
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync rc = RTSemMutexRelease(g_hMutex);
8e937899612528c862aad84d39ca073d231c3057vboxsync if (RT_FAILURE(rc))
8e937899612528c862aad84d39ca073d231c3057vboxsync {
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync PrintError("%x: RTSemMutexRelease failed with %Rrc\n", rc);
8e937899612528c862aad84d39ca073d231c3057vboxsync break;
8e937899612528c862aad84d39ca073d231c3057vboxsync }
8e937899612528c862aad84d39ca073d231c3057vboxsync if (g_fTerminate)
8e937899612528c862aad84d39ca073d231c3057vboxsync break;
8e937899612528c862aad84d39ca073d231c3057vboxsync }
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync if (!g_fQuiet)
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync RTPrintf("tstSemMutex: Thread %08x exited with %lld\n", ThreadSelf, *pu64);
8e937899612528c862aad84d39ca073d231c3057vboxsync return VINF_SUCCESS;
8e937899612528c862aad84d39ca073d231c3057vboxsync}
8e937899612528c862aad84d39ca073d231c3057vboxsync
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsyncstatic int Test1(unsigned cThreads, unsigned cSeconds, bool fYield, bool fQuiet)
8e937899612528c862aad84d39ca073d231c3057vboxsync{
8e937899612528c862aad84d39ca073d231c3057vboxsync int rc;
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync unsigned i;
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync uint64_t g_au64[32];
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync RTTHREAD aThreads[RT_ELEMENTS(g_au64)];
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync AssertRelease(cThreads <= RT_ELEMENTS(g_au64));
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync /*
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync * Init globals.
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync */
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync g_fYield = fYield;
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync g_fQuiet = fQuiet;
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync g_fTerminate = false;
8e937899612528c862aad84d39ca073d231c3057vboxsync
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync rc = RTSemMutexCreate(&g_hMutex);
8e937899612528c862aad84d39ca073d231c3057vboxsync if (RT_FAILURE(rc))
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync return PrintError("RTSemMutexCreate failed (rc=%Rrc)\n", rc);
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync /*
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync * Create the threads and let them block on the mutex.
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync */
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync rc = RTSemMutexRequest(g_hMutex, RT_INDEFINITE_WAIT);
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync if (RT_FAILURE(rc))
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync return PrintError("RTSemMutexRequest failed (rc=%Rrc)\n", rc);
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync for (i = 0; i < cThreads; i++)
8e937899612528c862aad84d39ca073d231c3057vboxsync {
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync g_au64[i] = 0;
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync rc = RTThreadCreate(&aThreads[i], ThreadTest1, &g_au64[i], 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "test");
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync if (RT_FAILURE(rc))
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync return PrintError("RTThreadCreate failed for thread %u (rc=%Rrc)\n", i, rc);
8e937899612528c862aad84d39ca073d231c3057vboxsync }
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync if (!fQuiet)
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync RTPrintf("tstSemMutex: %zu Threads created. Racing them for %u seconds (%s) ...\n",
e241ca160129baabbd80f3ad0eb2361ced172af6vboxsync cThreads, cSeconds, g_fYield ? "yielding" : "no yielding");
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync uint64_t u64StartTS = RTTimeNanoTS();
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync rc = RTSemMutexRelease(g_hMutex);
8e937899612528c862aad84d39ca073d231c3057vboxsync if (RT_FAILURE(rc))
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync PrintError("RTSemMutexRelease failed (rc=%Rrc)\n", rc);
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync RTThreadSleep(cSeconds * 1000);
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync ASMAtomicXchgBool(&g_fTerminate, true);
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync uint64_t ElapsedNS = RTTimeNanoTS() - u64StartTS;
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync for (i = 0; i < cThreads; i++)
8e937899612528c862aad84d39ca073d231c3057vboxsync {
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync rc = RTThreadWait(aThreads[i], 5000, NULL);
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync if (RT_FAILURE(rc))
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync PrintError("RTThreadWait failed for thread %u (rc=%Rrc)\n", i, rc);
8e937899612528c862aad84d39ca073d231c3057vboxsync }
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync rc = RTSemMutexDestroy(g_hMutex);
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync if (RT_FAILURE(rc))
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync PrintError("RTSemMutexDestroy failed - %Rrc\n", rc);
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync g_hMutex = NIL_RTSEMMUTEX;
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync if (g_cErrors)
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync RTThreadSleep(100);
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync /*
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync * Collect and display the results.
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync */
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync uint64_t Total = g_au64[0];
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync for (i = 1; i < cThreads; i++)
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync Total += g_au64[i];
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync uint64_t Normal = Total / cThreads;
23d5bb762e8ca9da3a3a89cb539de06e57b8fc03vboxsync uint64_t MaxDeviation = 0;
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync for (i = 0; i < cThreads; i++)
8e937899612528c862aad84d39ca073d231c3057vboxsync {
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync uint64_t Delta = RT_ABS((int64_t)(g_au64[i] - Normal));
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync if (Delta > Normal / 2)
7b3d8a8298d217445c72a3afaf7cc2e07f6d7d74vboxsync RTPrintf("tstSemMutex: Warning! Thread %d deviates by more than 50%% - %llu (it) vs. %llu (avg)\n",
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync i, g_au64[i], Normal);
23d5bb762e8ca9da3a3a89cb539de06e57b8fc03vboxsync if (Delta > MaxDeviation)
23d5bb762e8ca9da3a3a89cb539de06e57b8fc03vboxsync MaxDeviation = Delta;
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync
8e937899612528c862aad84d39ca073d231c3057vboxsync }
8e937899612528c862aad84d39ca073d231c3057vboxsync
23d5bb762e8ca9da3a3a89cb539de06e57b8fc03vboxsync RTPrintf("tstSemMutex: Threads: %u Total: %llu Per Sec: %llu Avg: %llu ns Max dev: %llu%%\n",
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync cThreads,
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync Total,
e241ca160129baabbd80f3ad0eb2361ced172af6vboxsync Total / cSeconds,
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync ElapsedNS / Total,
23d5bb762e8ca9da3a3a89cb539de06e57b8fc03vboxsync MaxDeviation * 100 / Normal
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync );
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync return 0;
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync}
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsyncint main(int argc, char **argv)
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync{
230bd8589bba39933ac5ec21482d6186d675e604vboxsync int rc = RTR3InitExe(argc, &argv, 0);
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync if (RT_FAILURE(rc))
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync {
230bd8589bba39933ac5ec21482d6186d675e604vboxsync RTPrintf("tstSemMutex: RTR3InitExe failed (rc=%Rrc)\n", rc);
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync return 1;
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync }
f716f1e4b9cf4d983c9cab4ed2edb32c349adcd1vboxsync RTPrintf("tstSemMutex: TESTING...\n");
8e937899612528c862aad84d39ca073d231c3057vboxsync
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync if (argc == 1)
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync {
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync /* threads, seconds, yield, quiet */
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync Test1( 1, 1, true, false);
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync Test1( 2, 1, true, false);
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync Test1( 10, 1, true, false);
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync Test1( 10, 10, false, false);
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync RTPrintf("tstSemMutex: benchmarking...\n");
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync for (unsigned cThreads = 1; cThreads < 32; cThreads++)
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync Test1(cThreads, 2, false, true);
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync /** @todo add a testcase where some stuff times out. */
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync }
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync else
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync {
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync /* threads, seconds, yield, quiet */
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync RTPrintf("tstSemMutex: benchmarking...\n");
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync Test1( 1, 3, false, true);
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync Test1( 1, 3, false, true);
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync Test1( 1, 3, false, true);
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync Test1( 2, 3, false, true);
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync Test1( 2, 3, false, true);
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync Test1( 2, 3, false, true);
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync Test1( 3, 3, false, true);
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync Test1( 3, 3, false, true);
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync Test1( 3, 3, false, true);
d2c8c88f63ecc894ada2baf184392c23856e74b6vboxsync }
8e937899612528c862aad84d39ca073d231c3057vboxsync
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync if (!g_cErrors)
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync RTPrintf("tstSemMutex: SUCCESS\n");
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync else
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync RTPrintf("tstSemMutex: FAILURE - %u errors\n", g_cErrors);
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync return g_cErrors != 0;
8e937899612528c862aad84d39ca073d231c3057vboxsync}
4d9067b4096dc07d546e2897b9bb7331da1a6ba9vboxsync