kernel: Implement thread pinning support (#2840)
* kernel: Implement Thread pinning support This commit adds support for 8.x thread pinning changes and implement SynchronizePreemptionState syscall. Based on kernel 13.x reverse. * Address gdkchan's comment * kernel: fix missing critical section leave in SetActivity Fix Unity games * Implement missing bits on the interrupt handler and inline update pinning function as it cannot be generic * Fix some bugs in SetActivity and SetCoreAndAffinityMask * Address gdkchan's comments
This commit is contained in:
parent
8544b1445b
commit
e96ef6d532
9 changed files with 436 additions and 95 deletions
|
@ -36,6 +36,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
|||
private readonly KThread _idleThread;
|
||||
|
||||
public KThread PreviousThread => _previousThread;
|
||||
public KThread CurrentThread => _currentThread;
|
||||
public long LastContextSwitchTime { get; private set; }
|
||||
public long TotalIdleTimeTicks => _idleThread.TotalTimeRunning;
|
||||
|
||||
|
@ -87,6 +88,26 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
|||
{
|
||||
KThread thread = context.PriorityQueue.ScheduledThreads(core).FirstOrDefault();
|
||||
|
||||
if (thread != null &&
|
||||
thread.Owner != null &&
|
||||
thread.Owner.PinnedThreads[core] != null &&
|
||||
thread.Owner.PinnedThreads[core] != thread)
|
||||
{
|
||||
KThread candidate = thread.Owner.PinnedThreads[core];
|
||||
|
||||
if (candidate.KernelWaitersCount == 0 && !thread.Owner.IsExceptionUserThread(candidate))
|
||||
{
|
||||
if (candidate.SchedFlags == ThreadSchedState.Running)
|
||||
{
|
||||
thread = candidate;
|
||||
}
|
||||
else
|
||||
{
|
||||
thread = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scheduledCoresMask |= context.Schedulers[core].SelectThread(thread);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue