From 2fd23577cea09a1c270678109ec728026df1cfda Mon Sep 17 00:00:00 2001
From: gdkchan <gab.dark.100@gmail.com>
Date: Wed, 24 Oct 2018 09:45:37 -0300
Subject: [PATCH] Move prio/core locals inside the lock on yield (#478)

---
 Ryujinx.HLE/HOS/Kernel/KThread.cs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Ryujinx.HLE/HOS/Kernel/KThread.cs b/Ryujinx.HLE/HOS/Kernel/KThread.cs
index aecaf6394..74ad28f36 100644
--- a/Ryujinx.HLE/HOS/Kernel/KThread.cs
+++ b/Ryujinx.HLE/HOS/Kernel/KThread.cs
@@ -226,11 +226,11 @@ namespace Ryujinx.HLE.HOS.Kernel
 
         public void YieldWithLoadBalancing()
         {
+            System.CriticalSectionLock.Lock();
+
             int Prio = DynamicPriority;
             int Core = CurrentCore;
 
-            System.CriticalSectionLock.Lock();
-
             if (SchedFlags != ThreadSchedState.Running)
             {
                 System.CriticalSectionLock.Unlock();