Changeset 45264 in vbox for trunk/src/VBox/Runtime/testcase
- Timestamp:
- Mar 31, 2013 12:40:20 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 84653
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstR0ThreadPreemptionDriver.cpp
r44529 r45264 30 30 #include <iprt/initterm.h> 31 31 32 #include <iprt/asm.h> 33 #include <iprt/cpuset.h> 32 34 #include <iprt/err.h> 33 35 #include <iprt/path.h> … … 42 44 #endif 43 45 46 /******************************************************************************* 47 * Global Variables * 48 *******************************************************************************/ 49 static bool volatile g_fTerminate = false; 50 51 52 /** 53 * Try make sure all online CPUs will be engaged. 54 */ 55 static DECLCALLBACK(int) MyThreadProc(RTTHREAD hSelf, void *pvCpuIdx) 56 { 57 RTCPUSET Affinity; 58 RTCpuSetEmpty(&Affinity); 59 RTCpuSetAddByIndex(&Affinity, (intptr_t)pvCpuIdx); 60 RTThreadSetAffinity(&Affinity); /* ignore return code as it's not supported on all hosts. */ 61 62 while (!g_fTerminate) 63 RTThreadSleep(50); 64 65 return VINF_SUCCESS; 66 } 67 44 68 45 69 int main(int argc, char **argv) … … 141 165 * Stay in ring-0 until preemption is pending. 142 166 */ 167 RTTHREAD ahThreads[RTCPUSET_MAX_CPUS]; 168 uint32_t cThreads = RTMpGetCount(); 169 RTCPUSET OnlineSet; 170 RTMpGetOnlineSet(&OnlineSet); 171 for (uint32_t i = 0; i < RT_ELEMENTS(ahThreads); i++) 172 { 173 ahThreads[i] = NIL_RTTHREAD; 174 if (RTCpuSetIsMemberByIndex(&OnlineSet, i)) 175 RTThreadCreateF(&ahThreads[i], MyThreadProc, (void *)(uintptr_t)i, 0, RTTHREADTYPE_DEFAULT, 176 RTTHREADFLAGS_WAITABLE, "cpu=%u", i); 177 } 178 143 179 RTThreadSleep(250); /** @todo fix GIP initialization? */ 180 144 181 RTTestSub(hTest, "Pending Preemption"); 145 182 for (int i = 0; ; i++) … … 163 200 } 164 201 202 ASMAtomicWriteBool(&g_fTerminate, true); 203 for (uint32_t i = 0; i < RT_ELEMENTS(ahThreads); i++) 204 if (ahThreads[i] != NIL_RTTHREAD) 205 RTThreadWait(ahThreads[i], 5000, NULL); 206 165 207 /* 166 208 * Test nested RTThreadPreemptDisable calls.
Note:
See TracChangeset
for help on using the changeset viewer.