mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-11-24 16:30:12 +01:00
Somewhat better implementation of thread yield
This commit is contained in:
parent
7f5a8effbb
commit
aa75957ce2
@ -196,6 +196,17 @@ namespace Ryujinx.Core.OsHle.Handles
|
||||
}
|
||||
|
||||
if (NeedsReschedule)
|
||||
{
|
||||
Yield(Thread, Thread.ActualPriority - 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void Yield(KThread Thread)
|
||||
{
|
||||
Yield(Thread, Thread.ActualPriority);
|
||||
}
|
||||
|
||||
private void Yield(KThread Thread, int MinPriority)
|
||||
{
|
||||
PrintDbgThreadInfo(Thread, "yielded execution.");
|
||||
|
||||
@ -203,7 +214,7 @@ namespace Ryujinx.Core.OsHle.Handles
|
||||
{
|
||||
int ActualCore = Thread.ActualCore;
|
||||
|
||||
SchedulerThread NewThread = WaitingToRun.Pop(ActualCore, Thread.ActualPriority);
|
||||
SchedulerThread NewThread = WaitingToRun.Pop(ActualCore, MinPriority);
|
||||
|
||||
if (NewThread == null)
|
||||
{
|
||||
@ -221,7 +232,6 @@ namespace Ryujinx.Core.OsHle.Handles
|
||||
|
||||
Resume(Thread);
|
||||
}
|
||||
}
|
||||
|
||||
public void Resume(KThread Thread)
|
||||
{
|
||||
|
@ -2,7 +2,7 @@ namespace Ryujinx.Core.OsHle.Handles
|
||||
{
|
||||
class ThreadQueue
|
||||
{
|
||||
private const int LowestPriority = 0x40;
|
||||
private const int LowestPriority = 0x3f;
|
||||
|
||||
private SchedulerThread Head;
|
||||
|
||||
@ -63,7 +63,7 @@ namespace Ryujinx.Core.OsHle.Handles
|
||||
{
|
||||
KThread Thread = Curr.Thread;
|
||||
|
||||
if (Thread.ActualPriority < MinPriority && (Thread.CoreMask & CoreMask) != 0)
|
||||
if (Thread.ActualPriority <= MinPriority && (Thread.CoreMask & CoreMask) != 0)
|
||||
{
|
||||
if (Prev != null)
|
||||
{
|
||||
|
@ -87,7 +87,7 @@ namespace Ryujinx.Core.OsHle.Kernel
|
||||
|
||||
if (TimeoutNs == 0)
|
||||
{
|
||||
Process.Scheduler.SetReschedule(CurrThread.ActualCore);
|
||||
Process.Scheduler.Yield(CurrThread);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -206,7 +206,7 @@ namespace Ryujinx.Core.OsHle.Kernel
|
||||
{
|
||||
lock (Process.ThreadSyncLock)
|
||||
{
|
||||
//This is the new thread that will not own the mutex.
|
||||
//This is the new thread that will now own the mutex.
|
||||
//If no threads are waiting for the lock, then it should be null.
|
||||
KThread OwnerThread = PopThread(CurrThread.MutexWaiters, x => x.MutexAddress == MutexAddress);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user