public void UnlockCPU() { int TlsLockCount = m_TlsIndex.Value; TlsLockCount--; System.Diagnostics.Debug.Assert(TlsLockCount >= 0); // ロック解除 if (TlsLockCount == 0) { m_SysSem.Release(); Interlocked.Decrement(ref m_Locked); } m_TlsIndex.Value = TlsLockCount; if (TlsLockCount == 0) { CPUContext LockCPUContext = CPUContext.GetCurrent(); if (LockCPUContext != null) { LockCPUContext.EndDelaySuspend(); } } }
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(); } } }
bool IKernel.ExitAndDispatch() { ExitCPUContext(CPUContext.GetCurrent()); return(true); }
ICPUContext IKernel.GetCurrent() { return /*m_Current*/ (CPUContext.GetCurrent()); }