Changeset 90665 in vbox
- Timestamp:
- Aug 12, 2021 2:29:37 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 146277
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/PDMAllCritSectRw.cpp
r90660 r90665 827 827 * gotten exclusive ownership of the critical section. 828 828 */ 829 DECLINLINE(int) pdmCritSectRwEnterExclFirst(PPDMCRITSECTRW pThis, PCRTLOCKVALSRCPOS pSrcPos, bool fNoVal, RTTHREAD hThreadSelf) 829 DECL_FORCE_INLINE(int) pdmCritSectRwEnterExclFirst(PPDMCRITSECTRW pThis, PCRTLOCKVALSRCPOS pSrcPos, 830 bool fNoVal, RTTHREAD hThreadSelf) 830 831 { 831 832 RT_NOREF(hThreadSelf, fNoVal, pSrcPos); … … 1071 1072 1072 1073 /* 1073 * Get cracking. 1074 */ 1075 uint64_t u64State = PDMCRITSECTRW_READ_STATE(&pThis->s.Core.u.s.u64State); 1074 * First we try grab an idle critical section using 128-bit atomics. 1075 */ 1076 /** @todo This could be moved up before the recursion check. */ 1077 uint64_t u64State = PDMCRITSECTRW_READ_STATE(&pThis->s.Core.u.s.u64State); 1078 #ifdef RTASM_HAVE_CMP_WRITE_U128 1079 if ( (u64State & ~RTCSRW_DIR_MASK) == 0 1080 && pdmCritSectRwIsCmpWriteU128Supported()) 1081 { 1082 RTCRITSECTRWSTATE OldState; 1083 OldState.s.u64State = u64State; 1084 OldState.s.hNativeWriter = NIL_RTNATIVETHREAD; 1085 AssertCompile(sizeof(OldState.s.hNativeWriter) == sizeof(OldState.u128.s.Lo)); 1086 1087 RTCRITSECTRWSTATE NewState; 1088 NewState.s.u64State = (UINT64_C(1) << RTCSRW_CNT_WR_SHIFT) | (RTCSRW_DIR_WRITE << RTCSRW_DIR_SHIFT); 1089 NewState.s.hNativeWriter = hNativeSelf; 1090 1091 if (ASMAtomicCmpWriteU128U(&pThis->s.Core.u.u128, NewState.u128, OldState.u128)) 1092 return pdmCritSectRwEnterExclFirst(pThis, pSrcPos, fNoVal, hThreadSelf); 1093 1094 u64State = PDMCRITSECTRW_READ_STATE(&pThis->s.Core.u.s.u64State); 1095 } 1096 #endif 1097 1098 /* 1099 * Do it step by step. Update the state to reflect our desire. 1100 */ 1076 1101 uint64_t u64OldState = u64State; 1077 1102 … … 1386 1411 AssertReturn(hNativeSelf == hNativeWriter, VERR_NOT_OWNER); 1387 1412 1413 1388 1414 /* 1389 1415 * Unwind one recursion. Not the last? … … 1410 1436 } 1411 1437 1438 1412 1439 /* 1413 1440 * Final recursion. … … 1424 1451 } 1425 1452 #endif 1453 1426 1454 1427 1455 #ifdef RTASM_HAVE_CMP_WRITE_U128 … … 1456 1484 } 1457 1485 } 1458 #endif 1486 #endif /* RTASM_HAVE_CMP_WRITE_U128 */ 1487 1459 1488 1460 1489 #if defined(IN_RING3) || defined(IN_RING0) … … 1566 1595 #endif /* IN_RING3 || IN_RING0 */ 1567 1596 1597 1568 1598 #ifndef IN_RING3 1569 1599 /*
Note:
See TracChangeset
for help on using the changeset viewer.