- Timestamp:
- Jul 8, 2014 5:45:51 PM (11 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/Makefile.kmk
r51868 r51940 1755 1755 common/time/timesup.cpp \ 1756 1756 generic/RTAssertShouldPanic-generic.cpp \ 1757 generic/critsect-generic.cpp \ 1757 1758 \ 1758 1759 $(RuntimeNoCrt_SOURCES) … … 1935 1936 generic/RTSemEventMultiWait-2-ex-generic.cpp \ 1936 1937 generic/RTSemEventMultiWaitNoResume-2-ex-generic.cpp \ 1938 generic/critsect-generic.cpp \ 1937 1939 generic/errvars-generic.cpp \ 1938 1940 generic/uuid-generic.cpp \ -
trunk/src/VBox/Runtime/generic/critsect-generic.cpp
r48935 r51940 59 59 */ 60 60 pCritSect->u32Magic = RTCRITSECT_MAGIC; 61 pCritSect->fFlags = fFlags; 61 #ifdef IN_RING0 62 pCritSect->fFlags = fFlags | RTCRITSECT_FLAGS_RING0; 63 #else 64 pCritSect->fFlags = fFlags & ~RTCRITSECT_FLAGS_RING0; 65 #endif 62 66 pCritSect->cNestings = 0; 63 67 pCritSect->cLockers = -1; … … 87 91 if (RT_SUCCESS(rc)) 88 92 { 93 #ifdef IN_RING0 94 rc = RTSemEventCreate(&pCritSect->EventSem); 95 96 #else 89 97 rc = RTSemEventCreateEx(&pCritSect->EventSem, 90 98 fFlags & RTCRITSECT_FLAGS_BOOTSTRAP_HACK … … 93 101 NIL_RTLOCKVALCLASS, 94 102 NULL); 103 #endif 95 104 if (RT_SUCCESS(rc)) 96 105 return VINF_SUCCESS; 106 #ifdef RTCRITSECT_STRICT 97 107 RTLockValidatorRecExclDestroy(&pCritSect->pValidatorRec); 108 #endif 98 109 } 99 110 … … 108 119 RTDECL(uint32_t) RTCritSectSetSubClass(PRTCRITSECT pCritSect, uint32_t uSubClass) 109 120 { 110 # ifdef RTCRITSECT_STRICT121 # ifdef RTCRITSECT_STRICT 111 122 AssertPtrReturn(pCritSect, RTLOCKVAL_SUB_CLASS_INVALID); 112 123 AssertReturn(pCritSect->u32Magic == RTCRITSECT_MAGIC, RTLOCKVAL_SUB_CLASS_INVALID); 113 124 AssertReturn(!(pCritSect->fFlags & RTCRITSECT_FLAGS_NOP), RTLOCKVAL_SUB_CLASS_INVALID); 114 125 return RTLockValidatorRecExclSetSubClass(pCritSect->pValidatorRec, uSubClass); 115 # else126 # else 116 127 return RTLOCKVAL_SUB_CLASS_INVALID; 117 # endif128 # endif 118 129 } 119 130 … … 124 135 Assert(pCritSect->u32Magic == RTCRITSECT_MAGIC); 125 136 /*AssertReturn(pCritSect->u32Magic == RTCRITSECT_MAGIC, VERR_SEM_DESTROYED);*/ 137 #ifdef IN_RING0 138 Assert(pCritSect->fFlags & RTCRITSECT_FLAGS_RING0); 139 #else 140 Assert(!(pCritSect->fFlags & RTCRITSECT_FLAGS_RING0)); 141 #endif 126 142 127 143 /* … … 196 212 AssertPtr(pCritSect); 197 213 AssertReturn(pCritSect->u32Magic == RTCRITSECT_MAGIC, VERR_SEM_DESTROYED); 214 #ifdef IN_RING0 215 Assert(pCritSect->fFlags & RTCRITSECT_FLAGS_RING0); 216 #else 217 Assert(!(pCritSect->fFlags & RTCRITSECT_FLAGS_RING0)); 218 #endif 198 219 199 220 /* … … 267 288 return rc9; 268 289 } 269 #el se290 #elif defined(IN_RING3) 270 291 RTThreadBlocking(hThreadSelf, RTTHREADSTATE_CRITSECT, false); 271 292 #endif 272 293 int rc = RTSemEventWait(pCritSect->EventSem, RT_INDEFINITE_WAIT); 294 #ifdef IN_RING3 273 295 RTThreadUnblocked(hThreadSelf, RTTHREADSTATE_CRITSECT); 296 #endif 274 297 275 298 if (pCritSect->u32Magic != RTCRITSECT_MAGIC) … … 322 345 Assert(pCritSect); 323 346 Assert(pCritSect->u32Magic == RTCRITSECT_MAGIC); 347 #ifdef IN_RING0 348 Assert(pCritSect->fFlags & RTCRITSECT_FLAGS_RING0); 349 #else 350 Assert(!(pCritSect->fFlags & RTCRITSECT_FLAGS_RING0)); 351 #endif 324 352 if (pCritSect->fFlags & RTCRITSECT_FLAGS_NOP) 325 353 return VINF_SUCCESS; … … 363 391 364 392 365 393 #ifdef IN_RING3 366 394 367 395 static int rtCritSectEnterMultiple(size_t cCritSects, PRTCRITSECT *papCritSects, PCRTLOCKVALSRCPOS pSrcPos) … … 477 505 RT_EXPORT_SYMBOL(RTCritSectLeaveMultiple); 478 506 507 #endif /* IN_RING3 */ 508 509 479 510 480 511 RTDECL(int) RTCritSectDelete(PRTCRITSECT pCritSect) … … 488 519 Assert(pCritSect->cLockers == -1); 489 520 Assert(pCritSect->NativeThreadOwner == NIL_RTNATIVETHREAD); 521 #ifdef IN_RING0 522 Assert(pCritSect->fFlags & RTCRITSECT_FLAGS_RING0); 523 #else 524 Assert(!(pCritSect->fFlags & RTCRITSECT_FLAGS_RING0)); 525 #endif 490 526 491 527 /* … … 506 542 AssertRC(rc); 507 543 544 #ifdef RTCRITSECT_STRICT 508 545 RTLockValidatorRecExclDestroy(&pCritSect->pValidatorRec); 546 #endif 509 547 510 548 return rc; -
trunk/src/VBox/VMM/VMMR0/GMMR0.cpp
r49789 r51940 165 165 # include <iprt/crc.h> 166 166 #endif 167 #include <iprt/critsect.h> 167 168 #include <iprt/list.h> 168 169 #include <iprt/mem.h> … … 172 173 #include <iprt/string.h> 173 174 #include <iprt/time.h> 175 176 177 /******************************************************************************* 178 * Defined Constants And Macros * 179 *******************************************************************************/ 180 /** @def VBOX_USE_CRIT_SECT_FOR_GIANT 181 * Use a critical section instead of a fast mutex for the giant GMM lock. 182 * 183 * @remarks This is primarily a way of avoiding the deadlock checks in the 184 * windows driver verifier. */ 185 #if defined(RT_OS_WINDOWS) || defined(DOXYGEN_RUNNING) 186 # define VBOX_USE_CRIT_SECT_FOR_GIANT 187 #endif 174 188 175 189 … … 476 490 /** The number of threads waiting on the mutex. */ 477 491 uint32_t cMtxContenders; 492 #ifdef VBOX_USE_CRIT_SECT_FOR_GIANT 493 /** The critical section protecting the GMM. 494 * More fine grained locking can be implemented later if necessary. */ 495 RTCRITSECT GiantCritSect; 496 #else 478 497 /** The fast mutex protecting the GMM. 479 498 * More fine grained locking can be implemented later if necessary. */ 480 499 RTSEMFASTMUTEX hMtx; 500 #endif 481 501 #ifdef VBOX_STRICT 482 502 /** The current mutex owner. */ … … 758 778 ASMBitSet(&pGMM->bmChunkId[0], NIL_GMM_CHUNKID); 759 779 780 #ifdef VBOX_USE_CRIT_SECT_FOR_GIANT 781 int rc = RTCritSectInit(&pGMM->GiantCritSect); 782 #else 760 783 int rc = RTSemFastMutexCreate(&pGMM->hMtx); 784 #endif 761 785 if (RT_SUCCESS(rc)) 762 786 { … … 816 840 while (iMtx-- > 0) 817 841 RTSemFastMutexDestroy(pGMM->aChunkMtx[iMtx].hMtx); 842 #ifdef VBOX_USE_CRIT_SECT_FOR_GIANT 843 RTCritSectDelete(&pGMM->GiantCritSect); 844 #else 818 845 RTSemFastMutexDestroy(pGMM->hMtx); 846 #endif 819 847 } 820 848 … … 851 879 g_pGMM = NULL; 852 880 pGMM->u32Magic = ~GMM_MAGIC; 881 #ifdef VBOX_USE_CRIT_SECT_FOR_GIANT 882 RTCritSectDelete(&pGMM->GiantCritSect); 883 #else 853 884 RTSemFastMutexDestroy(pGMM->hMtx); 854 885 pGMM->hMtx = NIL_RTSEMFASTMUTEX; 886 #endif 855 887 856 888 /* Free any chunks still hanging around. */ … … 933 965 { 934 966 ASMAtomicIncU32(&pGMM->cMtxContenders); 967 #ifdef VBOX_USE_CRIT_SECT_FOR_GIANT 968 int rc = RTCritSectEnter(&pGMM->GiantCritSect); 969 #else 935 970 int rc = RTSemFastMutexRequest(pGMM->hMtx); 971 #endif 936 972 ASMAtomicDecU32(&pGMM->cMtxContenders); 937 973 AssertRC(rc); … … 954 990 pGMM->hMtxOwner = NIL_RTNATIVETHREAD; 955 991 #endif 992 #ifdef VBOX_USE_CRIT_SECT_FOR_GIANT 993 int rc = RTCritSectLeave(&pGMM->GiantCritSect); 994 #else 956 995 int rc = RTSemFastMutexRelease(pGMM->hMtx); 957 996 AssertRC(rc); 997 #endif 958 998 return rc; 959 999 } … … 991 1031 #endif 992 1032 ASMAtomicIncU32(&pGMM->cMtxContenders); 1033 #ifdef VBOX_USE_CRIT_SECT_FOR_GIANT 1034 int rc1 = RTCritSectLeave(&pGMM->GiantCritSect); AssertRC(rc1); 1035 #else 993 1036 int rc1 = RTSemFastMutexRelease(pGMM->hMtx); AssertRC(rc1); 1037 #endif 994 1038 995 1039 RTThreadYield(); 996 1040 1041 #ifdef VBOX_USE_CRIT_SECT_FOR_GIANT 1042 int rc2 = RTCritSectEnter(&pGMM->GiantCritSect); AssertRC(rc2); 1043 #else 997 1044 int rc2 = RTSemFastMutexRequest(pGMM->hMtx); AssertRC(rc2); 1045 #endif 998 1046 *puLockNanoTS = RTTimeSystemNanoTS(); 999 1047 ASMAtomicDecU32(&pGMM->cMtxContenders);
Note:
See TracChangeset
for help on using the changeset viewer.