CPUContext StartDelaySuspend() { CPUContext CPUContext = CPUContext.GetCurrent(); if (CPUContext != null) { CPUContext.StartDelaySuspend(); } return(CPUContext); }
public void LockCPU() { int TlsLockCount = m_TlsIndex.Value; // 他のスレッドが動かないようロック if (TlsLockCount == 0) { Interlocked.Increment(ref m_Locked); for (;;) { if (!m_SysSem.WaitOne()) { Terminate(); break; } // 実行を意図したスレッドかチェック CPUContext Context = CPUContext.GetCurrent(); if ((Context == null) || (Context == m_Current) || (m_Current == null)) { break; } if (!InKernelMode()) { m_IntEvent.Set(); } // 実行したくないスレッドはもう一度待つ m_SysSem.Release(); Thread.Yield(); } } TlsLockCount++; m_TlsIndex.Value = TlsLockCount; if (TlsLockCount == 1) { CPUContext LockCPUContext = CPUContext.GetCurrent(); if (LockCPUContext != null) { LockCPUContext.StartDelaySuspend(); } } }