tstSemMutex.cpp revision 230bd8589bba39933ac5ec21482d6186d675e604
767N/A * IPRT Testcase - Simple Mutex Semaphore Smoke Test. 98N/A * Copyright (C) 2006-2007 Oracle Corporation 98N/A * This file is part of VirtualBox Open Source Edition (OSE), as 98N/A * you can redistribute it and/or modify it under the terms of the GNU 98N/A * General Public License (GPL) as published by the Free Software 98N/A * Foundation, in version 2 as it comes in the "COPYING" file of the 98N/A * VirtualBox OSE distribution. VirtualBox OSE is distributed in the 98N/A * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 98N/A * The contents of this file may alternatively be used under the terms 98N/A * of the Common Development and Distribution License Version 1.0 98N/A * (CDDL) only, as it comes in the "COPYING.CDDL" file of the 98N/A * VirtualBox OSE distribution, in which case the provisions of the 98N/A * CDDL are applicable instead of those of the GPL. 98N/A * You may elect to license modified versions of this file under the 98N/A * terms and conditions of either the GPL or the CDDL or both. 98N/A/******************************************************************************* 98N/A*******************************************************************************/ 911N/A/******************************************************************************* 98N/A*******************************************************************************/ PrintError(
"%x: RTSemMutexRequestNoResume failed with %Rrc\n",
rc);
* Check for fairness: The values of the threads should not differ too much * Check for correctness: Give other threads a chance. If the implementation is * correct, no other thread will be able to enter this lock now. return PrintError(
"RTSemMutexCreate failed (rc=%Rrc)\n",
rc);
* Create the threads and let them block on the mutex. return PrintError(
"RTSemMutexRequest failed (rc=%Rrc)\n",
rc);
return PrintError(
"RTThreadCreate failed for thread %u (rc=%Rrc)\n", i,
rc);
RTPrintf(
"tstSemMutex: %zu Threads created. Racing them for %u seconds (%s) ...\n",
PrintError(
"RTThreadWait failed for thread %u (rc=%Rrc)\n", i,
rc);
* Collect and display the results. RTPrintf(
"tstSemMutex: Warning! Thread %d deviates by more than 50%% - %llu (it) vs. %llu (avg)\n",
RTPrintf(
"tstSemMutex: Threads: %u Total: %llu Per Sec: %llu Avg: %llu ns Max dev: %llu%%\n",
RTPrintf(
"tstSemMutex: RTR3InitExe failed (rc=%Rrc)\n",
rc);
/* threads, seconds, yield, quiet */ Test1(
1,
1,
true,
false);
Test1(
2,
1,
true,
false);
Test1(
10,
1,
true,
false);
Test1(
10,
10,
false,
false);
RTPrintf(
"tstSemMutex: benchmarking...\n");
/** @todo add a testcase where some stuff times out. */ /* threads, seconds, yield, quiet */ RTPrintf(
"tstSemMutex: benchmarking...\n");
Test1(
1,
3,
false,
true);
Test1(
1,
3,
false,
true);
Test1(
1,
3,
false,
true);
Test1(
2,
3,
false,
true);
Test1(
2,
3,
false,
true);
Test1(
2,
3,
false,
true);
Test1(
3,
3,
false,
true);
Test1(
3,
3,
false,
true);
Test1(
3,
3,
false,
true);