[*] (optimize) RunOSWaitOnAddressEQNoTimedNoErrors wasn't NT aware

This commit is contained in:
Reece Wilson 2024-04-28 14:13:09 +01:00
parent 7e9a9417db
commit 9d4c5a8cfc
2 changed files with 10 additions and 9 deletions

View File

@ -51,8 +51,8 @@ namespace Aurora::Threading
} }
static ProcessWaitContainer gProcessWaitables; static ProcessWaitContainer gProcessWaitables;
static int gShouldSpinOnlyInCPU = 1; // TODO: havent decided static const int gShouldSpinOnlyInCPU = 1; // TODO: havent decided
// UPDATE: 1 paranoia just in case we get preempted (rare).
template<typename T> template<typename T>
static void DoSpinLockOnVar(T *uPointer) static void DoSpinLockOnVar(T *uPointer)
{ {
@ -969,7 +969,7 @@ namespace Aurora::Threading
const void *pCompareAddress, const void *pCompareAddress,
WaitState &state) WaitState &state)
{ {
while (WaitBuffer::Compare2<EWaitMethod::eNotEqual, AuBuild::kIsNTDerived>(pTargetAddress, state.uWordSize, pCompareAddress, state.uDownsizeMask)) while (WaitBuffer::Compare2<EWaitMethod::eNotEqual, kPlatformFutexNoForcedAlignedU32>(pTargetAddress, state.uWordSize, pCompareAddress, state.uDownsizeMask))
{ {
if (!SysWaitOnAddressNoTimed(pTargetAddress, pCompareAddress, state.uWordSize)) if (!SysWaitOnAddressNoTimed(pTargetAddress, pCompareAddress, state.uWordSize))
{ {
@ -984,13 +984,13 @@ namespace Aurora::Threading
bool bSpun = false) bool bSpun = false)
{ {
#if 1 #if 1
if (!WaitBuffer::Compare2<EWaitMethod::eNotEqual, AuBuild::kIsNTDerived>(pTargetAddress, state.uWordSize, pCompareAddress, state.uDownsizeMask)) if (!WaitBuffer::Compare2<EWaitMethod::eNotEqual, kPlatformFutexNoForcedAlignedU32>(pTargetAddress, state.uWordSize, pCompareAddress, state.uDownsizeMask))
{ {
return true; return true;
} }
(void)RunOSWaitOnAddressTimed(pTargetAddress, pCompareAddress, state.uWordSize, state.qwNanosecondsAbs.value(), { }, { }, bSpun); (void)RunOSWaitOnAddressTimed(pTargetAddress, pCompareAddress, state.uWordSize, state.qwNanosecondsAbs.value(), { }, { }, bSpun);
return !WaitBuffer::Compare2<EWaitMethod::eNotEqual, AuBuild::kIsNTDerived>(pTargetAddress, state.uWordSize, pCompareAddress, state.uDownsizeMask); return !WaitBuffer::Compare2<EWaitMethod::eNotEqual, kPlatformFutexNoForcedAlignedU32>(pTargetAddress, state.uWordSize, pCompareAddress, state.uDownsizeMask);
#else #else
return RunOSWaitOnAddressTimed(pTargetAddress, pCompareAddress, state.uWordSize, state.qwNanosecondsAbs.value(), { }, { }, bSpun); return RunOSWaitOnAddressTimed(pTargetAddress, pCompareAddress, state.uWordSize, state.qwNanosecondsAbs.value(), { }, { }, bSpun);
#endif #endif
@ -1005,14 +1005,14 @@ namespace Aurora::Threading
{ {
WaitBuffer wb = WaitBuffer::From(pTargetAddress, state.uWordSize); WaitBuffer wb = WaitBuffer::From(pTargetAddress, state.uWordSize);
if (!WaitBuffer::Compare2<T>(wb.buffer, state.uWordSize, pCompareAddress, state.uDownsizeMask)) if (!WaitBuffer::Compare2<T, kPlatformFutexNoForcedAlignedU32>(wb.buffer, state.uWordSize, pCompareAddress, state.uDownsizeMask))
{ {
return; return;
} }
(void)SysWaitOnAddressNoTimed(pTargetAddress, wb.buffer, state.uWordSize); (void)SysWaitOnAddressNoTimed(pTargetAddress, wb.buffer, state.uWordSize);
if (WaitBuffer::Compare2<T>(pTargetAddress, state.uWordSize, pCompareAddress, state.uDownsizeMask)) if (WaitBuffer::Compare2<T, kPlatformFutexNoForcedAlignedU32>(pTargetAddress, state.uWordSize, pCompareAddress, state.uDownsizeMask))
{ {
SysWakeOneOnAddress(pTargetAddress); SysWakeOneOnAddress(pTargetAddress);
} }
@ -1033,14 +1033,14 @@ namespace Aurora::Threading
{ {
WaitBuffer wb = WaitBuffer::From(pTargetAddress, state.uWordSize); WaitBuffer wb = WaitBuffer::From(pTargetAddress, state.uWordSize);
if (!WaitBuffer::Compare2<T, AuBuild::kIsNtDerived>(wb.buffer, state.uWordSize, pCompareAddress, state.uDownsizeMask)) if (!WaitBuffer::Compare2<T, kPlatformFutexNoForcedAlignedU32>(wb.buffer, state.uWordSize, pCompareAddress, state.uDownsizeMask))
{ {
return true; return true;
} }
bool bResult = RunOSWaitOnAddressTimed(pTargetAddress, wb.buffer, state.uWordSize, state.qwNanosecondsAbs.value(), { }, { }, bSpun); bool bResult = RunOSWaitOnAddressTimed(pTargetAddress, wb.buffer, state.uWordSize, state.qwNanosecondsAbs.value(), { }, { }, bSpun);
if (WaitBuffer::Compare2<T, AuBuild::kIsNtDerived>(pTargetAddress, state.uWordSize, pCompareAddress, state.uDownsizeMask)) if (WaitBuffer::Compare2<T, kPlatformFutexNoForcedAlignedU32>(pTargetAddress, state.uWordSize, pCompareAddress, state.uDownsizeMask))
{ {
SysWakeOneOnAddress(pTargetAddress); SysWakeOneOnAddress(pTargetAddress);
if (!bResult) if (!bResult)

View File

@ -25,6 +25,7 @@ namespace Aurora::Threading
{ {
static const auto kDefaultWaitPerProcess = 128; static const auto kDefaultWaitPerProcess = 128;
static const auto kMax64 = 0xFFFFFFFFFFFFFFFFull; static const auto kMax64 = 0xFFFFFFFFFFFFFFFFull;
static const auto kPlatformFutexNoForcedAlignedU32 = AuBuild::kIsNTDerived;
struct WaitState; struct WaitState;