Changeset 40806 in vbox for trunk/src/VBox/Runtime/common/misc/thread.cpp
- Timestamp:
- Apr 6, 2012 9:05:19 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 77321
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/thread.cpp
r39456 r40806 58 58 *******************************************************************************/ 59 59 #ifdef IN_RING0 60 # define RT_THREAD_LOCK_TMP(Tmp) RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER 61 # define RT_THREAD_LOCK_RW(Tmp) RTSpinlockAcquireNoInts(g_ThreadSpinlock, &(Tmp)) 62 # define RT_THREAD_UNLOCK_RW(Tmp) RTSpinlockReleaseNoInts(g_ThreadSpinlock, &(Tmp)) 63 # define RT_THREAD_LOCK_RD(Tmp) RTSpinlockAcquireNoInts(g_ThreadSpinlock, &(Tmp)) 64 # define RT_THREAD_UNLOCK_RD(Tmp) RTSpinlockReleaseNoInts(g_ThreadSpinlock, &(Tmp)) 60 # define RT_THREAD_LOCK_RW() RTSpinlockAcquire(g_ThreadSpinlock) 61 # define RT_THREAD_UNLOCK_RW() RTSpinlockRelease(g_ThreadSpinlock) 62 # define RT_THREAD_LOCK_RD() RTSpinlockAcquire(g_ThreadSpinlock) 63 # define RT_THREAD_UNLOCK_RD() RTSpinlockRelease(g_ThreadSpinlock) 65 64 #else 66 # define RT_THREAD_LOCK_TMP(Tmp) 67 # define RT_THREAD_LOCK_RW(Tmp) rtThreadLockRW() 68 # define RT_THREAD_UNLOCK_RW(Tmp) rtThreadUnLockRW() 69 # define RT_THREAD_LOCK_RD(Tmp) rtThreadLockRD() 70 # define RT_THREAD_UNLOCK_RD(Tmp) rtThreadUnLockRD() 65 # define RT_THREAD_LOCK_RW() rtThreadLockRW() 66 # define RT_THREAD_UNLOCK_RW() rtThreadUnLockRW() 67 # define RT_THREAD_LOCK_RD() rtThreadLockRD() 68 # define RT_THREAD_UNLOCK_RD() rtThreadUnLockRD() 71 69 #endif 72 70 … … 167 165 */ 168 166 Assert(g_ThreadSpinlock == NIL_RTSPINLOCK); 169 rc = RTSpinlockCreate(&g_ThreadSpinlock );167 rc = RTSpinlockCreate(&g_ThreadSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "RTThread"); 170 168 if (RT_SUCCESS(rc)) 171 169 { … … 406 404 407 405 { 408 RT_THREAD_LOCK_TMP(Tmp); 409 RT_THREAD_LOCK_RW(Tmp); 406 RT_THREAD_LOCK_RW(); 410 407 411 408 /* … … 450 447 } 451 448 452 RT_THREAD_UNLOCK_RW( Tmp);449 RT_THREAD_UNLOCK_RW(); 453 450 } 454 451 } … … 479 476 static void rtThreadRemove(PRTTHREADINT pThread) 480 477 { 481 RT_THREAD_LOCK_TMP(Tmp); 482 RT_THREAD_LOCK_RW(Tmp); 478 RT_THREAD_LOCK_RW(); 483 479 if (ASMAtomicBitTestAndClear(&pThread->fIntFlags, RTTHREADINT_FLAG_IN_TREE_BIT)) 484 480 rtThreadRemoveLocked(pThread); 485 RT_THREAD_UNLOCK_RW( Tmp);481 RT_THREAD_UNLOCK_RW(); 486 482 } 487 483 … … 512 508 * Simple tree lookup. 513 509 */ 514 RT_THREAD_LOCK_TMP(Tmp); 515 RT_THREAD_LOCK_RD(Tmp); 510 RT_THREAD_LOCK_RD(); 516 511 pThread = (PRTTHREADINT)RTAvlPVGet(&g_ThreadTree, (void *)NativeThread); 517 RT_THREAD_UNLOCK_RD( Tmp);512 RT_THREAD_UNLOCK_RD(); 518 513 return pThread; 519 514 } … … 1241 1236 * Do the job. 1242 1237 */ 1243 RT_THREAD_LOCK_TMP(Tmp); 1244 RT_THREAD_LOCK_RW(Tmp); 1238 RT_THREAD_LOCK_RW(); 1245 1239 rc = rtThreadNativeSetPriority(pThread, enmType); 1246 1240 if (RT_SUCCESS(rc)) 1247 1241 ASMAtomicXchgSize(&pThread->enmType, enmType); 1248 RT_THREAD_UNLOCK_RW( Tmp);1242 RT_THREAD_UNLOCK_RW(); 1249 1243 if (RT_FAILURE(rc)) 1250 1244 Log(("RTThreadSetType: failed on thread %p (%s), rc=%Rrc!!!\n", Thread, pThread->szName, rc)); … … 1302 1296 int rtThreadDoCalcDefaultPriority(RTTHREADTYPE enmType) 1303 1297 { 1304 RT_THREAD_LOCK_TMP(Tmp); 1305 RT_THREAD_LOCK_RW(Tmp); 1298 RT_THREAD_LOCK_RW(); 1306 1299 int rc = rtSchedNativeCalcDefaultPriority(enmType); 1307 RT_THREAD_UNLOCK_RW( Tmp);1300 RT_THREAD_UNLOCK_RW(); 1308 1301 return rc; 1309 1302 } … … 1350 1343 * scheduling attributes defined by the specified process priority. 1351 1344 */ 1352 RT_THREAD_LOCK_TMP(Tmp); 1353 RT_THREAD_LOCK_RW(Tmp); 1345 RT_THREAD_LOCK_RW(); 1354 1346 int rc = rtProcNativeSetPriority(enmPriority); 1355 1347 if (RT_SUCCESS(rc)) … … 1370 1362 } 1371 1363 } 1372 RT_THREAD_UNLOCK_RW( Tmp);1364 RT_THREAD_UNLOCK_RW(); 1373 1365 LogFlow(("rtThreadDoSetProcPriority: returns %Rrc\n", rc)); 1374 1366 return rc; … … 1526 1518 DECLHIDDEN(void) rtThreadClearTlsEntry(RTTLS iTls) 1527 1519 { 1528 RT_THREAD_LOCK_TMP(Tmp); 1529 RT_THREAD_LOCK_RD(Tmp); 1520 RT_THREAD_LOCK_RD(); 1530 1521 RTAvlPVDoWithAll(&g_ThreadTree, true /* fFromLeft*/, rtThreadClearTlsEntryCallback, (void *)(uintptr_t)iTls); 1531 RT_THREAD_UNLOCK_RD( Tmp);1522 RT_THREAD_UNLOCK_RD(); 1532 1523 } 1533 1524
Note:
See TracChangeset
for help on using the changeset viewer.