1
1
mirror of https://github.com/ryujinx-mirror/ryujinx.git synced 2025-09-22 08:42:01 -05:00

Somewhat better scheduler I guess

This commit is contained in:
gdkchan
2018-02-19 16:37:13 -03:00
parent 8df0b62fe0
commit 770cb4b655
10 changed files with 323 additions and 282 deletions

View File

@@ -4,6 +4,7 @@ using Ryujinx.OsHle.Exceptions;
using Ryujinx.OsHle.Handles;
using Ryujinx.OsHle.Ipc;
using System;
using System.Threading;
namespace Ryujinx.OsHle.Svc
{
@@ -37,16 +38,10 @@ namespace Ryujinx.OsHle.Svc
//TODO: Implement events.
//Logging.Info($"SvcWaitSynchronization Thread {ThreadState.ThreadId}");
HThread CurrThread = Process.GetThread(ThreadState.Tpidr);
if (Process.TryGetThread(ThreadState.Tpidr, out HThread Thread))
{
Process.Scheduler.Yield(Thread);
}
else
{
Logging.Error($"Thread with TPIDR_EL0 0x{ThreadState.Tpidr:x16} not found!");
}
Process.Scheduler.Suspend(CurrThread.ProcessorId);
Process.Scheduler.Resume(CurrThread);
ThreadState.X0 = (int)SvcResult.Success;
}
@@ -99,6 +94,10 @@ namespace Ryujinx.OsHle.Svc
Handle = (int)ThreadState.X0;
}
HThread CurrThread = Process.GetThread(ThreadState.Tpidr);
Process.Scheduler.Suspend(CurrThread.ProcessorId);
byte[] CmdData = AMemoryHelper.ReadBytes(Memory, CmdPtr, (int)Size);
HSession Session = Ns.Os.Handles.GetData<HSession>(Handle);
@@ -117,6 +116,10 @@ namespace Ryujinx.OsHle.Svc
{
ThreadState.X0 = (int)SvcResult.ErrBadIpcReq;
}
Thread.Yield();
Process.Scheduler.Resume(CurrThread);
}
private void SvcBreak(AThreadState ThreadState)

View File

@@ -1,6 +1,5 @@
using ChocolArm64.State;
using Ryujinx.OsHle.Handles;
using System.Threading;
namespace Ryujinx.OsHle.Svc
{
@@ -18,6 +17,7 @@ namespace Ryujinx.OsHle.Svc
{
if (ProcessorId == -2)
{
//TODO: Get this value from the NPDM file.
ProcessorId = 0;
}
@@ -55,16 +55,16 @@ namespace Ryujinx.OsHle.Svc
{
ulong NanoSecs = ThreadState.X0;
if (Process.TryGetThread(ThreadState.Tpidr, out HThread CurrThread))
HThread CurrThread = Process.GetThread(ThreadState.Tpidr);
if (NanoSecs == 0)
{
Process.Scheduler.Yield(CurrThread);
}
else
{
Logging.Error($"Thread with TPIDR_EL0 0x{ThreadState.Tpidr:x16} not found!");
Process.Scheduler.WaitForSignal(CurrThread, (int)(NanoSecs / 1000000));
}
Thread.Sleep((int)(NanoSecs / 1000000));
}
private void SvcGetThreadPriority(AThreadState ThreadState)

View File

@@ -43,10 +43,11 @@ namespace Ryujinx.OsHle.Svc
HThread Thread = Ns.Os.Handles.GetData<HThread>(ThreadHandle);
if (Ns.Os.Mutexes.TryGetValue(MutexAddress, out Mutex M))
{
M.GiveUpLock(ThreadHandle);
}
Mutex M = new Mutex(Process, MutexAddress, ThreadHandle);
M = Ns.Os.Mutexes.GetOrAdd(MutexAddress, M);
M.GiveUpLock(ThreadHandle);
CondVar Cv = new CondVar(Process, CondVarAddress, Timeout);
@@ -54,10 +55,6 @@ namespace Ryujinx.OsHle.Svc
Cv.WaitForSignal(Thread);
M = new Mutex(Process, MutexAddress, ThreadHandle);
M = Ns.Os.Mutexes.GetOrAdd(MutexAddress, M);
M.WaitForLock(Thread, ThreadHandle);
ThreadState.X0 = (int)SvcResult.Success;
@@ -68,9 +65,11 @@ namespace Ryujinx.OsHle.Svc
long CondVarAddress = (long)ThreadState.X0;
int Count = (int)ThreadState.X1;
HThread CurrThread = Process.GetThread(ThreadState.Tpidr);
if (Ns.Os.CondVars.TryGetValue(CondVarAddress, out CondVar Cv))
{
Cv.SetSignal(Count);
Cv.SetSignal(CurrThread, Count);
}
ThreadState.X0 = (int)SvcResult.Success;