public void Resume(HThread CurrThread) { SchedulerThread SchedThread; Logging.Debug($"{GetDbgThreadInfo(CurrThread)} entering ipc delay wait state."); lock (SchedLock) { if (!AllThreads.TryGetValue(CurrThread, out SchedThread)) { Logging.Error($"{GetDbgThreadInfo(CurrThread)} was not found on the scheduler queue!"); return; } } TryResumingExecution(SchedThread); }
private void TryResumingExecution(SchedulerThread SchedThread) { HThread Thread = SchedThread.Thread; lock (SchedLock) { if (ActiveProcessors.Add(Thread.ProcessorId)) { Logging.Debug($"{GetDbgThreadInfo(Thread)} resuming execution..."); return; } WaitingToRun[Thread.ProcessorId].Push(SchedThread); } SchedThread.WaitEvent.WaitOne(); Logging.Debug($"{GetDbgThreadInfo(Thread)} resuming execution..."); }
public void WaitForSignal(HThread Thread, int Timeout = -1) { SchedulerThread SchedThread; Logging.Debug($"{GetDbgThreadInfo(Thread)} entering signal wait state."); lock (SchedLock) { SchedThread = WaitingToRun[Thread.ProcessorId].Pop(); if (SchedThread != null) { RunThread(SchedThread); } else { ActiveProcessors.Remove(Thread.ProcessorId); } if (!AllThreads.TryGetValue(Thread, out SchedThread)) { Logging.Error($"{GetDbgThreadInfo(Thread)} was not found on the scheduler queue!"); return; } } if (Timeout >= 0) { Logging.Debug($"{GetDbgThreadInfo(Thread)} has wait timeout of {Timeout}ms."); SchedThread.WaitEvent.WaitOne(Timeout); } else { SchedThread.WaitEvent.WaitOne(); } TryResumingExecution(SchedThread); }
private string GetDbgThreadInfo(HThread Thread) { return($"Thread {Thread.ThreadId} (core {Thread.ProcessorId}) prio {Thread.Priority}"); }
public SchedulerThread(HThread Thread) { this.Thread = Thread; WaitEvent = new AutoResetEvent(false); }