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
This commit is contained in:
parent
33e2810ef3
commit
b8133c1997
57 changed files with 3262 additions and 1540 deletions
|
@ -41,7 +41,7 @@ namespace ChocolArm64.Memory
|
|||
}
|
||||
}
|
||||
|
||||
private Dictionary<AThreadState, ArmMonitor> Monitors;
|
||||
private Dictionary<int, ArmMonitor> Monitors;
|
||||
|
||||
private ConcurrentDictionary<long, IntPtr> ObservedPages;
|
||||
|
||||
|
@ -53,7 +53,7 @@ namespace ChocolArm64.Memory
|
|||
|
||||
public AMemory(IntPtr Ram)
|
||||
{
|
||||
Monitors = new Dictionary<AThreadState, ArmMonitor>();
|
||||
Monitors = new Dictionary<int, ArmMonitor>();
|
||||
|
||||
ObservedPages = new ConcurrentDictionary<long, IntPtr>();
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue