public void ChangeCore(KThread Thread, int IdealCore, int CoreMask) { lock (SchedLock) { if (IdealCore != -3) { Thread.IdealCore = IdealCore; } Thread.CoreMask = CoreMask; if (AllThreads.ContainsKey(Thread)) { SetReschedule(Thread.ActualCore); SchedulerThread SchedThread = AllThreads[Thread]; //Note: Aways if the thread is on the queue first, and try //adding to a new core later, to ensure that a thread that //is already running won't be added to another core. if (WaitingToRun.HasThread(SchedThread) && TryAddToCore(Thread)) { WaitingToRun.Remove(SchedThread); RunThread(SchedThread); } } } }
public void TryToRun(KThread Thread) { lock (SchedLock) { if (AllThreads.TryGetValue(Thread, out SchedulerThread SchedThread)) { if (WaitingToRun.HasThread(SchedThread) && TryAddToCore(Thread)) { RunThread(SchedThread); } else { SetReschedule(Thread.ProcessorId); } } } }