From 48278905d1470f89be31668c738397f569af156a Mon Sep 17 00:00:00 2001 From: gdkchan Date: Wed, 9 Dec 2020 19:20:05 -0300 Subject: Rewrite scheduler context switch code (#1786) * Rewrite scheduler context switch code * Fix race in UnmapIpcRestorePermission * Fix thread exit issue that could leave the scheduler in a invalid state * Change context switch method to not wait on guest thread, remove spin wait, use SignalAndWait to pass control * Remove multi-core setting (it is always on now) * Re-enable assert * Remove multicore from default config and schema * Fix race in KTimeManager --- Ryujinx.HLE/HOS/Kernel/Threading/HleCoreManager.cs | 66 ---------------------- 1 file changed, 66 deletions(-) delete mode 100644 Ryujinx.HLE/HOS/Kernel/Threading/HleCoreManager.cs (limited to 'Ryujinx.HLE/HOS/Kernel/Threading/HleCoreManager.cs') diff --git a/Ryujinx.HLE/HOS/Kernel/Threading/HleCoreManager.cs b/Ryujinx.HLE/HOS/Kernel/Threading/HleCoreManager.cs deleted file mode 100644 index c2597990..00000000 --- a/Ryujinx.HLE/HOS/Kernel/Threading/HleCoreManager.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System.Collections.Concurrent; -using System.Threading; - -namespace Ryujinx.HLE.HOS.Kernel.Threading -{ - class HleCoreManager - { - private class PausableThread - { - public ManualResetEvent Event { get; private set; } - - public bool IsExiting { get; set; } - - public PausableThread() - { - Event = new ManualResetEvent(false); - } - } - - private ConcurrentDictionary _threads; - - public HleCoreManager() - { - _threads = new ConcurrentDictionary(); - } - - public void Set(Thread thread) - { - GetThread(thread).Event.Set(); - } - - public void Reset(Thread thread) - { - GetThread(thread).Event.Reset(); - } - - public void Wait(Thread thread) - { - PausableThread pausableThread = GetThread(thread); - - if (!pausableThread.IsExiting) - { - pausableThread.Event.WaitOne(); - } - } - - public void Exit(Thread thread) - { - GetThread(thread).IsExiting = true; - } - - private PausableThread GetThread(Thread thread) - { - return _threads.GetOrAdd(thread, (key) => new PausableThread()); - } - - public void RemoveThread(Thread thread) - { - if (_threads.TryRemove(thread, out PausableThread pausableThread)) - { - pausableThread.Event.Set(); - pausableThread.Event.Dispose(); - } - } - } -} \ No newline at end of file -- cgit v1.2.3