Move ProcessId and ThreadId out of AThreadState

This commit is contained in:
gdkchan 2018-08-16 12:36:34 -03:00
parent 7fa094f137
commit 4f05b53121
6 changed files with 18 additions and 23 deletions

View file

@ -18,8 +18,6 @@ namespace ChocolArm64
public event EventHandler WorkFinished;
public int ThreadId => ThreadState.ThreadId;
private int IsExecuting;
public AThread(ATranslator Translator, AMemory Memory, long EntryPoint)

View file

@ -41,7 +41,7 @@ namespace ChocolArm64.Memory
}
}
private Dictionary<int, ArmMonitor> Monitors;
private Dictionary<AThreadState, ArmMonitor> Monitors;
private ConcurrentDictionary<long, IntPtr> ObservedPages;
@ -53,7 +53,7 @@ namespace ChocolArm64.Memory
public AMemory(IntPtr Ram)
{
Monitors = new Dictionary<int, ArmMonitor>();
Monitors = new Dictionary<AThreadState, ArmMonitor>();
ObservedPages = new ConcurrentDictionary<long, IntPtr>();
@ -75,7 +75,7 @@ namespace ChocolArm64.Memory
{
ClearExclusive(State);
Monitors.Remove(State.ThreadId);
Monitors.Remove(State);
}
}
@ -93,11 +93,11 @@ namespace ChocolArm64.Memory
}
}
if (!Monitors.TryGetValue(ThreadState.ThreadId, out ArmMonitor ThreadMon))
if (!Monitors.TryGetValue(ThreadState, out ArmMonitor ThreadMon))
{
ThreadMon = new ArmMonitor();
Monitors.Add(ThreadState.ThreadId, ThreadMon);
Monitors.Add(ThreadState, ThreadMon);
}
ThreadMon.Position = Position;
@ -113,7 +113,7 @@ namespace ChocolArm64.Memory
Monitor.Enter(Monitors);
if (!Monitors.TryGetValue(ThreadState.ThreadId, out ArmMonitor ThreadMon))
if (!Monitors.TryGetValue(ThreadState, out ArmMonitor ThreadMon))
{
return false;
}
@ -130,7 +130,7 @@ namespace ChocolArm64.Memory
public void ClearExclusiveForStore(AThreadState ThreadState)
{
if (Monitors.TryGetValue(ThreadState.ThreadId, out ArmMonitor ThreadMon))
if (Monitors.TryGetValue(ThreadState, out ArmMonitor ThreadMon))
{
ThreadMon.ExState = false;
}
@ -142,7 +142,7 @@ namespace ChocolArm64.Memory
{
lock (Monitors)
{
if (Monitors.TryGetValue(ThreadState.ThreadId, out ArmMonitor ThreadMon))
if (Monitors.TryGetValue(ThreadState, out ArmMonitor ThreadMon))
{
ThreadMon.ExState = false;
}

View file

@ -40,9 +40,6 @@ namespace ChocolArm64.State
public bool Zero;
public bool Negative;
public int ProcessId;
public int ThreadId;
public bool Running { get; set; }
public long TpidrEl0 { get; set; }

View file

@ -33,18 +33,20 @@ namespace Ryujinx.HLE.HOS.Kernel
public long LastPc { get; set; }
public int ThreadId => Thread.ThreadId;
public int ThreadId { get; private set; }
public KThread(
AThread Thread,
Process Process,
int ProcessorId,
int Priority)
int Priority,
int ThreadId)
{
this.Thread = Thread;
this.Process = Process;
this.ProcessorId = ProcessorId;
this.IdealCore = ProcessorId;
this.ThreadId = ThreadId;
MutexWaiters = new List<KThread>();

View file

@ -19,7 +19,7 @@ namespace Ryujinx.HLE.HOS.Kernel
private void SvcExitProcess(AThreadState ThreadState)
{
Device.System.ExitProcess(ThreadState.ProcessId);
Device.System.ExitProcess(Process.ProcessId);
}
private void SvcClearEvent(AThreadState ThreadState)

View file

@ -194,18 +194,16 @@ namespace Ryujinx.HLE.HOS
AThread CpuThread = new AThread(GetTranslator(), Memory, EntryPoint);
KThread Thread = new KThread(CpuThread, this, ProcessorId, Priority);
long Tpidr = GetFreeTls();
int ThreadId = (int)((Tpidr - MemoryManager.TlsIoRegionStart) / 0x200) + 1;
KThread Thread = new KThread(CpuThread, this, ProcessorId, Priority, ThreadId);
Thread.LastPc = EntryPoint;
int Handle = HandleTable.OpenHandle(Thread);
long Tpidr = GetFreeTls();
int ThreadId = (int)((Tpidr - MemoryManager.TlsIoRegionStart) / 0x200) + 1;
CpuThread.ThreadState.ProcessId = ProcessId;
CpuThread.ThreadState.ThreadId = ThreadId;
CpuThread.ThreadState.CntfrqEl0 = TickFreq;
CpuThread.ThreadState.Tpidr = Tpidr;