From b8be89ab2dad2e2ba5145f64425fa49526f81596 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 26 Jun 2018 01:26:21 -0300 Subject: [PATCH] Relax GetThreadContext3 by allowing it to get the context of a running thread --- .../OsHle/Handles/KProcessScheduler.cs | 20 ------------------- Ryujinx.HLE/OsHle/Handles/SchedulerThread.cs | 2 -- Ryujinx.HLE/OsHle/Kernel/SvcThread.cs | 9 --------- 3 files changed, 31 deletions(-) diff --git a/Ryujinx.HLE/OsHle/Handles/KProcessScheduler.cs b/Ryujinx.HLE/OsHle/Handles/KProcessScheduler.cs index 011d975426..7d5e228460 100644 --- a/Ryujinx.HLE/OsHle/Handles/KProcessScheduler.cs +++ b/Ryujinx.HLE/OsHle/Handles/KProcessScheduler.cs @@ -47,8 +47,6 @@ namespace Ryujinx.HLE.OsHle.Handles if (TryAddToCore(Thread)) { - SchedThread.IsRunning = true; - Thread.Thread.Execute(); PrintDbgThreadInfo(Thread, "running."); @@ -110,16 +108,6 @@ namespace Ryujinx.HLE.OsHle.Handles } } - public bool IsThreadRunning(KThread Thread) - { - if (!AllThreads.TryGetValue(Thread, out SchedulerThread SchedThread)) - { - return false; - } - - return SchedThread.IsRunning; - } - public void EnterWait(KThread Thread, int TimeoutMs = Timeout.Infinite) { SchedulerThread SchedThread = AllThreads[Thread]; @@ -170,8 +158,6 @@ namespace Ryujinx.HLE.OsHle.Handles { lock (SchedLock) { - AllThreads[Thread].IsRunning = false; - PrintDbgThreadInfo(Thread, "suspended."); int ActualCore = Thread.ActualCore; @@ -263,8 +249,6 @@ namespace Ryujinx.HLE.OsHle.Handles private void TryResumingExecution(SchedulerThread SchedThread) { - SchedThread.IsRunning = false; - KThread Thread = SchedThread.Thread; PrintDbgThreadInfo(Thread, "trying to resume..."); @@ -275,8 +259,6 @@ namespace Ryujinx.HLE.OsHle.Handles { if (TryAddToCore(Thread)) { - SchedThread.IsRunning = true; - PrintDbgThreadInfo(Thread, "resuming execution..."); return; @@ -306,8 +288,6 @@ namespace Ryujinx.HLE.OsHle.Handles { PrintDbgThreadInfo(SchedThread.Thread, "running."); } - - SchedThread.IsRunning = true; } public void Resort(KThread Thread) diff --git a/Ryujinx.HLE/OsHle/Handles/SchedulerThread.cs b/Ryujinx.HLE/OsHle/Handles/SchedulerThread.cs index 0b7a3c30f7..5bdefe74e9 100644 --- a/Ryujinx.HLE/OsHle/Handles/SchedulerThread.cs +++ b/Ryujinx.HLE/OsHle/Handles/SchedulerThread.cs @@ -11,8 +11,6 @@ namespace Ryujinx.HLE.OsHle.Handles public bool IsActive { get; set; } - public bool IsRunning { get; set; } - public AutoResetEvent WaitSync { get; private set; } public ManualResetEvent WaitActivity { get; private set; } public AutoResetEvent WaitSched { get; private set; } diff --git a/Ryujinx.HLE/OsHle/Kernel/SvcThread.cs b/Ryujinx.HLE/OsHle/Kernel/SvcThread.cs index 543d9fd2c9..b0a7490a39 100644 --- a/Ryujinx.HLE/OsHle/Kernel/SvcThread.cs +++ b/Ryujinx.HLE/OsHle/Kernel/SvcThread.cs @@ -306,15 +306,6 @@ namespace Ryujinx.HLE.OsHle.Kernel return; } - if (Process.Scheduler.IsThreadRunning(Thread)) - { - Ns.Log.PrintWarning(LogClass.KernelSvc, $"Thread handle 0x{Handle:x8} is running!"); - - ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidState); - - return; - } - Memory.WriteUInt64(Position + 0x0, ThreadState.X0); Memory.WriteUInt64(Position + 0x8, ThreadState.X1); Memory.WriteUInt64(Position + 0x10, ThreadState.X2);