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/State/AThreadState.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'ChocolArm64/State/AThreadState.cs') diff --git a/ChocolArm64/State/AThreadState.cs b/ChocolArm64/State/AThreadState.cs index 7b69d817..783f5a12 100644 --- a/ChocolArm64/State/AThreadState.cs +++ b/ChocolArm64/State/AThreadState.cs @@ -41,6 +41,9 @@ namespace ChocolArm64.State public bool Negative; public bool Running { get; set; } + public int Core { get; set; } + + private bool Interrupted; public long TpidrEl0 { get; set; } public long Tpidr { get; set; } @@ -73,6 +76,7 @@ namespace ChocolArm64.State } } + public event EventHandler Interrupt; public event EventHandler Break; public event EventHandler SvcCall; public event EventHandler Undefined; @@ -99,9 +103,26 @@ namespace ChocolArm64.State internal bool Synchronize() { + if (Interrupted) + { + Interrupted = false; + + OnInterrupt(); + } + return Running; } + internal void RequestInterrupt() + { + Interrupted = true; + } + + private void OnInterrupt() + { + Interrupt?.Invoke(this, EventArgs.Empty); + } + internal void OnBreak(long Position, int Imm) { Break?.Invoke(this, new AInstExceptionEventArgs(Position, Imm)); -- cgit v1.2.3