KiFastExitThreadWait

VOID __stdcall KiFastExitThreadWait(_KPRCB *Prcb, _ETHREAD *Thread, UINT8 ExitScheduler){
  int v6[10]; 
  UINT64 SpinCount; 

  Thread->Tcb.WaitBlockFill6[68] = 2;
  _InterlockedOr(v6, 0);
  if( Thread->Tcb.ThreadLock )
  {
    LODWORD(SpinCount) = 0;
    while( _interlockedbittestandset64((volatile signed __int32 *)&Thread->Tcb.ThreadLock, 0i64) )
    {
      do
        KeYieldProcessorEx(&SpinCount);
      while( Thread->Tcb.ThreadLock );
    }
    KiReleaseThreadLockSafe((INT64)Thread);
  }
  KiExitThreadWait(Prcb, &Thread->Tcb, ExitScheduler);
}

Referenced by:

KeDelayExecutionThread
KeRemovePriQueue
KeRemoveQueueEx
KeWaitForAlertByThreadId
KeWaitForGate
KeWaitForSingleObject
KiWaitForAllObjects