Made initial implementation of the thread scheduler, refactor Svc to avoid passing many arguments
This commit is contained in:
parent
598d1fd3ae
commit
f68696dc4a
19 changed files with 740 additions and 252 deletions
|
@ -10,8 +10,13 @@ namespace ChocolArm64
|
|||
public ARegisters Registers { get; private set; }
|
||||
public AMemory Memory { get; private set; }
|
||||
|
||||
public long EntryPoint { get; private set; }
|
||||
|
||||
private ATranslator Translator;
|
||||
private Thread Work;
|
||||
|
||||
private ThreadPriority Priority;
|
||||
|
||||
private Thread Work;
|
||||
|
||||
public event EventHandler WorkFinished;
|
||||
|
||||
|
@ -19,25 +24,35 @@ namespace ChocolArm64
|
|||
|
||||
public bool IsAlive => Work.IsAlive;
|
||||
|
||||
public long EntryPoint { get; private set; }
|
||||
public int Priority { get; private set; }
|
||||
private bool IsExecuting;
|
||||
|
||||
public AThread(AMemory Memory, long EntryPoint = 0, int Priority = 0)
|
||||
private object ExecuteLock;
|
||||
|
||||
public AThread(AMemory Memory, ThreadPriority Priority, long EntryPoint)
|
||||
{
|
||||
this.Memory = Memory;
|
||||
this.EntryPoint = EntryPoint;
|
||||
this.Priority = Priority;
|
||||
this.EntryPoint = EntryPoint;
|
||||
|
||||
Registers = new ARegisters();
|
||||
Translator = new ATranslator(this);
|
||||
Registers = new ARegisters();
|
||||
Translator = new ATranslator(this);
|
||||
ExecuteLock = new object();
|
||||
}
|
||||
|
||||
public void StopExecution() => Translator.StopExecution();
|
||||
|
||||
public void Execute() => Execute(EntryPoint);
|
||||
|
||||
public void Execute(long EntryPoint)
|
||||
public bool Execute()
|
||||
{
|
||||
lock (ExecuteLock)
|
||||
{
|
||||
if (IsExecuting)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
IsExecuting = true;
|
||||
}
|
||||
|
||||
Work = new Thread(delegate()
|
||||
{
|
||||
Translator.ExecuteSubroutine(EntryPoint);
|
||||
|
@ -47,28 +62,11 @@ namespace ChocolArm64
|
|||
WorkFinished?.Invoke(this, EventArgs.Empty);
|
||||
});
|
||||
|
||||
if (Priority < 12)
|
||||
{
|
||||
Work.Priority = ThreadPriority.Highest;
|
||||
}
|
||||
else if (Priority < 24)
|
||||
{
|
||||
Work.Priority = ThreadPriority.AboveNormal;
|
||||
}
|
||||
else if (Priority < 36)
|
||||
{
|
||||
Work.Priority = ThreadPriority.Normal;
|
||||
}
|
||||
else if (Priority < 48)
|
||||
{
|
||||
Work.Priority = ThreadPriority.BelowNormal;
|
||||
}
|
||||
else
|
||||
{
|
||||
Work.Priority = ThreadPriority.Lowest;
|
||||
}
|
||||
Work.Priority = Priority;
|
||||
|
||||
Work.Start();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue