From b8133c19971c7a2026af803003fafedbdb70488e Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 18 Sep 2018 20:36:43 -0300 Subject: Thread scheduler rewrite (#393) * Started to rewrite the thread scheduler * Add a single core-like scheduling mode, enabled by default * Clear exclusive monitor on context switch * Add SetThreadActivity, misc fixes * Implement WaitForAddress and SignalToAddress svcs, misc fixes * Misc fixes (on SetActivity and Arbiter), other tweaks * Rebased * Add missing null check * Rename multicore key on config, fix UpdatePriorityInheritance * Make scheduling data MLQs private * nit: Ordering --- ChocolArm64/Memory/AMemory.cs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'ChocolArm64/Memory') diff --git a/ChocolArm64/Memory/AMemory.cs b/ChocolArm64/Memory/AMemory.cs index 806a0b86..2cb9b16c 100644 --- a/ChocolArm64/Memory/AMemory.cs +++ b/ChocolArm64/Memory/AMemory.cs @@ -41,7 +41,7 @@ namespace ChocolArm64.Memory } } - private Dictionary Monitors; + private Dictionary Monitors; private ConcurrentDictionary ObservedPages; @@ -53,7 +53,7 @@ namespace ChocolArm64.Memory public AMemory(IntPtr Ram) { - Monitors = new Dictionary(); + Monitors = new Dictionary(); ObservedPages = new ConcurrentDictionary(); @@ -69,17 +69,17 @@ namespace ChocolArm64.Memory } } - public void RemoveMonitor(AThreadState State) + public void RemoveMonitor(int Core) { lock (Monitors) { - ClearExclusive(State); + ClearExclusive(Core); - Monitors.Remove(State); + Monitors.Remove(Core); } } - public void SetExclusive(AThreadState ThreadState, long Position) + public void SetExclusive(int Core, long Position) { Position &= ~ErgMask; @@ -93,11 +93,11 @@ namespace ChocolArm64.Memory } } - if (!Monitors.TryGetValue(ThreadState, out ArmMonitor ThreadMon)) + if (!Monitors.TryGetValue(Core, out ArmMonitor ThreadMon)) { ThreadMon = new ArmMonitor(); - Monitors.Add(ThreadState, ThreadMon); + Monitors.Add(Core, ThreadMon); } ThreadMon.Position = Position; @@ -105,7 +105,7 @@ namespace ChocolArm64.Memory } } - public bool TestExclusive(AThreadState ThreadState, long Position) + public bool TestExclusive(int Core, long Position) { //Note: Any call to this method also should be followed by a //call to ClearExclusiveForStore if this method returns true. @@ -113,7 +113,7 @@ namespace ChocolArm64.Memory Monitor.Enter(Monitors); - if (!Monitors.TryGetValue(ThreadState, out ArmMonitor ThreadMon)) + if (!Monitors.TryGetValue(Core, out ArmMonitor ThreadMon)) { return false; } @@ -128,9 +128,9 @@ namespace ChocolArm64.Memory return ExState; } - public void ClearExclusiveForStore(AThreadState ThreadState) + public void ClearExclusiveForStore(int Core) { - if (Monitors.TryGetValue(ThreadState, out ArmMonitor ThreadMon)) + if (Monitors.TryGetValue(Core, out ArmMonitor ThreadMon)) { ThreadMon.ExState = false; } @@ -138,11 +138,11 @@ namespace ChocolArm64.Memory Monitor.Exit(Monitors); } - public void ClearExclusive(AThreadState ThreadState) + public void ClearExclusive(int Core) { lock (Monitors) { - if (Monitors.TryGetValue(ThreadState, out ArmMonitor ThreadMon)) + if (Monitors.TryGetValue(Core, out ArmMonitor ThreadMon)) { ThreadMon.ExState = false; } -- cgit v1.2.3