Changeset 10947 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Jul 29, 2008 6:27:35 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 33813
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstOnce.cpp
r10940 r10947 47 47 static int g_cErrors = 0; 48 48 static bool g_fOnceCB1 = false; 49 static uint32_t volatile g_cOnceCB2 = 0; 49 static uint32_t volatile g_cOnce2CB = 0; 50 static bool volatile g_fOnce2Ready = false; 50 51 static RTONCE g_Once2 = RTONCE_INITIALIZER; 51 52 static RTSEMEVENTMULTI g_hEventMulti = NIL_RTSEMEVENTMULTI; … … 68 69 static DECLCALLBACK(int) Once2CB(void *pvUser1, void *pvUser2) 69 70 { 70 if (ASMAtomicIncU32(&g_cOnce CB2) != 1)71 if (ASMAtomicIncU32(&g_cOnce2CB) != 1) 71 72 { 72 RTPrintf("tstOnce: ERROR - Once2CB: g_cOnce CB2not zero!\n");73 RTPrintf("tstOnce: ERROR - Once2CB: g_cOnce2CB not zero!\n"); 73 74 g_cErrors++; 74 75 return VERR_WRONG_ORDER; … … 80 81 return VERR_INVALID_PARAMETER; 81 82 } 83 RTThreadSleep(2); 84 Assert(!g_fOnce2Ready); 85 ASMAtomicWriteBool(&g_fOnce2Ready, true); 82 86 return VINF_SUCCESS; 83 87 } … … 90 94 if (RT_FAILURE(rc)) 91 95 return rc; 92 return RTOnce(&g_Once2, Once2CB, (void *)42, (void *)1); 96 rc = RTOnce(&g_Once2, Once2CB, (void *)42, (void *)1); 97 if (RT_SUCCESS(rc)) 98 { 99 if (!ASMAtomicUoReadBool(&g_fOnce2Ready)) 100 { 101 RTPrintf("tstOnce: ERROR - Once2CB: Not initialized!\n"); 102 g_cErrors++; 103 } 104 } 105 return rc; 93 106 } 94 107 … … 97 110 { 98 111 RTR3Init(); 99 RTPrintf("tstOnce: SUCCESS\n");100 112 101 113 /* 102 114 * Just a simple testcase. 103 115 */ 116 RTPrintf("tstOnce: TESTING - smoke...\n"); 104 117 RTONCE Once1 = RTONCE_INITIALIZER; 105 118 g_fOnceCB1 = false; … … 115 128 * Throw a bunch of threads up against a init once thing. 116 129 */ 130 RTPrintf("tstOnce: TESTING - bunch of threads...\n"); 117 131 /* create the semaphore they'll be waiting on. */ 118 132 rc = RTSemEventMultiCreate(&g_hEventMulti);
Note:
See TracChangeset
for help on using the changeset viewer.