aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Kernel/Threading
diff options
context:
space:
mode:
authorAlex Barney <thealexbarney@gmail.com>2019-07-01 21:39:22 -0500
committerAc_K <Acoustik666@gmail.com>2019-07-02 04:39:22 +0200
commitb2b736abc2569ab5d8199da666aef8d8394844a0 (patch)
tree88bcc2ae4fb0d4161c95df2cd7edb12388de922a /Ryujinx.HLE/HOS/Kernel/Threading
parent10c74182babaf8cf6bedaeffd64c3109df4ea816 (diff)
Misc cleanup (#708)
* Fix typos * Remove unneeded using statements * Enforce var style more * Remove redundant qualifiers * Fix some indentation * Disable naming warnings on files with external enum names * Fix build * Mass find & replace for comments with no spacing * Standardize todo capitalization and for/if spacing
Diffstat (limited to 'Ryujinx.HLE/HOS/Kernel/Threading')
-rw-r--r--Ryujinx.HLE/HOS/Kernel/Threading/HleScheduler.cs18
-rw-r--r--Ryujinx.HLE/HOS/Kernel/Threading/KAddressArbiter.cs22
-rw-r--r--Ryujinx.HLE/HOS/Kernel/Threading/KCriticalSection.cs6
-rw-r--r--Ryujinx.HLE/HOS/Kernel/Threading/KScheduler.cs34
-rw-r--r--Ryujinx.HLE/HOS/Kernel/Threading/KSynchronization.cs2
-rw-r--r--Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs44
6 files changed, 63 insertions, 63 deletions
diff --git a/Ryujinx.HLE/HOS/Kernel/Threading/HleScheduler.cs b/Ryujinx.HLE/HOS/Kernel/Threading/HleScheduler.cs
index d5dbb4d8..42eed26a 100644
--- a/Ryujinx.HLE/HOS/Kernel/Threading/HleScheduler.cs
+++ b/Ryujinx.HLE/HOS/Kernel/Threading/HleScheduler.cs
@@ -68,8 +68,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
if (hasThreadExecuting)
{
- //If this is not the thread that is currently executing, we need
- //to request an interrupt to allow safely starting another thread.
+ // If this is not the thread that is currently executing, we need
+ // to request an interrupt to allow safely starting another thread.
if (!currentThread.Context.IsCurrentThread())
{
currentThread.Context.RequestInterrupt();
@@ -80,8 +80,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
CoreManager.Reset(currentThread.Context.Work);
}
- //Advance current core and try picking a thread,
- //keep advancing if it is null.
+ // Advance current core and try picking a thread,
+ // keep advancing if it is null.
for (int core = 0; core < 4; core++)
{
_currentCore = (_currentCore + 1) % CpuCoresCount;
@@ -100,8 +100,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
}
}
- //If nothing was running before, then we are on a "external"
- //HLE thread, we don't need to wait.
+ // If nothing was running before, then we are on a "external"
+ // HLE thread, we don't need to wait.
if (!hasThreadExecuting)
{
return;
@@ -114,9 +114,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
private void PreemptCurrentThread()
{
- //Preempts current thread every 10 milliseconds on a round-robin fashion,
- //when multi core scheduling is disabled, to try ensuring that all threads
- //gets a chance to run.
+ // Preempts current thread every 10 milliseconds on a round-robin fashion,
+ // when multi core scheduling is disabled, to try ensuring that all threads
+ // gets a chance to run.
while (_keepPreempting)
{
lock (CoreContexts)
diff --git a/Ryujinx.HLE/HOS/Kernel/Threading/KAddressArbiter.cs b/Ryujinx.HLE/HOS/Kernel/Threading/KAddressArbiter.cs
index b11df61e..166cf064 100644
--- a/Ryujinx.HLE/HOS/Kernel/Threading/KAddressArbiter.cs
+++ b/Ryujinx.HLE/HOS/Kernel/Threading/KAddressArbiter.cs
@@ -207,7 +207,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
signaledThreads.Enqueue(thread);
- //If the count is <= 0, we should signal all threads waiting.
+ // If the count is <= 0, we should signal all threads waiting.
if (count >= 1 && --count == 0)
{
break;
@@ -234,7 +234,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
{
if (!KernelTransfer.UserToKernelInt32(_system, address, out mutexValue))
{
- //Invalid address.
+ // Invalid address.
requester.SignaledObj = null;
requester.ObjSyncResult = KernelResult.InvalidMemState;
@@ -243,12 +243,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
if (mutexValue != 0)
{
- //Update value to indicate there is a mutex waiter now.
+ // Update value to indicate there is a mutex waiter now.
newMutexValue = mutexValue | HasListenersMask;
}
else
{
- //No thread owning the mutex, assign to requesting thread.
+ // No thread owning the mutex, assign to requesting thread.
newMutexValue = requester.ThreadHandleForUserMutex;
}
}
@@ -256,7 +256,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
if (mutexValue == 0)
{
- //We now own the mutex.
+ // We now own the mutex.
requester.SignaledObj = null;
requester.ObjSyncResult = KernelResult.Success;
@@ -271,12 +271,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
if (mutexOwner != null)
{
- //Mutex already belongs to another thread, wait for it.
+ // Mutex already belongs to another thread, wait for it.
mutexOwner.AddMutexWaiter(requester);
}
else
{
- //Invalid mutex owner.
+ // Invalid mutex owner.
requester.SignaledObj = null;
requester.ObjSyncResult = KernelResult.InvalidHandle;
@@ -513,9 +513,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
int offset;
- //The value is decremented if the number of threads waiting is less
- //or equal to the Count of threads to be signaled, or Count is zero
- //or negative. It is incremented if there are no threads waiting.
+ // The value is decremented if the number of threads waiting is less
+ // or equal to the Count of threads to be signaled, or Count is zero
+ // or negative. It is incremented if there are no threads waiting.
int waitingCount = 0;
foreach (KThread thread in ArbiterThreads.Where(x => x.MutexAddress == address))
@@ -572,7 +572,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
{
signaledThreads.Enqueue(thread);
- //If the count is <= 0, we should signal all threads waiting.
+ // If the count is <= 0, we should signal all threads waiting.
if (count >= 1 && --count == 0)
{
break;
diff --git a/Ryujinx.HLE/HOS/Kernel/Threading/KCriticalSection.cs b/Ryujinx.HLE/HOS/Kernel/Threading/KCriticalSection.cs
index 841d0d69..39c857b5 100644
--- a/Ryujinx.HLE/HOS/Kernel/Threading/KCriticalSection.cs
+++ b/Ryujinx.HLE/HOS/Kernel/Threading/KCriticalSection.cs
@@ -57,17 +57,17 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
if (currentHleThread == null)
{
- //Nothing is running, we can perform the context switch immediately.
+ // Nothing is running, we can perform the context switch immediately.
coreContext.ContextSwitch();
}
else if (currentHleThread.IsCurrentThread())
{
- //Thread running on the current core, context switch will block.
+ // Thread running on the current core, context switch will block.
doContextSwitch = true;
}
else
{
- //Thread running on another core, request a interrupt.
+ // Thread running on another core, request a interrupt.
currentHleThread.RequestInterrupt();
}
}
diff --git a/Ryujinx.HLE/HOS/Kernel/Threading/KScheduler.cs b/Ryujinx.HLE/HOS/Kernel/Threading/KScheduler.cs
index c9686df3..8d2cdfce 100644
--- a/Ryujinx.HLE/HOS/Kernel/Threading/KScheduler.cs
+++ b/Ryujinx.HLE/HOS/Kernel/Threading/KScheduler.cs
@@ -55,7 +55,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
KThread selectedThread = scheduledThreads.FirstOrDefault(x => x.DynamicPriority == prio);
- //Yield priority queue.
+ // Yield priority queue.
if (selectedThread != null)
{
SchedulingData.Reschedule(prio, core, selectedThread);
@@ -82,7 +82,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
}
}
- //If the candidate was scheduled after the current thread, then it's not worth it.
+ // If the candidate was scheduled after the current thread, then it's not worth it.
if (selectedThread == null || selectedThread.LastScheduledTime >= thread.LastScheduledTime)
{
yield return thread;
@@ -90,8 +90,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
}
}
- //Select candidate threads that could run on this core.
- //Only take into account threads that are not yet selected.
+ // Select candidate threads that could run on this core.
+ // Only take into account threads that are not yet selected.
KThread dst = SuitableCandidates().FirstOrDefault(x => x.DynamicPriority == prio);
if (dst != null)
@@ -101,8 +101,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
selectedThread = dst;
}
- //If the priority of the currently selected thread is lower than preemption priority,
- //then allow threads with lower priorities to be selected aswell.
+ // If the priority of the currently selected thread is lower than preemption priority,
+ // then allow threads with lower priorities to be selected aswell.
if (selectedThread != null && selectedThread.DynamicPriority > prio)
{
Func<KThread, bool> predicate = x => x.DynamicPriority >= selectedThread.DynamicPriority;
@@ -131,8 +131,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
for (int core = 0; core < CpuCoresCount; core++)
{
- //If the core is not idle (there's already a thread running on it),
- //then we don't need to attempt load balancing.
+ // If the core is not idle (there's already a thread running on it),
+ // then we don't need to attempt load balancing.
if (SchedulingData.ScheduledThreads(core).Any())
{
continue;
@@ -144,8 +144,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
KThread dst = null;
- //Select candidate threads that could run on this core.
- //Give preference to threads that are not yet selected.
+ // Select candidate threads that could run on this core.
+ // Give preference to threads that are not yet selected.
foreach (KThread thread in SchedulingData.SuggestedThreads(core))
{
if (thread.CurrentCore < 0 || thread != CoreContexts[thread.CurrentCore].SelectedThread)
@@ -158,11 +158,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
srcCoresHighestPrioThreads[srcCoresHighestPrioThreadsCount++] = thread.CurrentCore;
}
- //Not yet selected candidate found.
+ // Not yet selected candidate found.
if (dst != null)
{
- //Priorities < 2 are used for the kernel message dispatching
- //threads, we should skip load balancing entirely.
+ // Priorities < 2 are used for the kernel message dispatching
+ // threads, we should skip load balancing entirely.
if (dst.DynamicPriority >= 2)
{
SchedulingData.TransferToCore(dst.DynamicPriority, core, dst);
@@ -173,8 +173,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
continue;
}
- //All candiates are already selected, choose the best one
- //(the first one that doesn't make the source core idle if moved).
+ // All candidates are already selected, choose the best one
+ // (the first one that doesn't make the source core idle if moved).
for (int index = 0; index < srcCoresHighestPrioThreadsCount; index++)
{
int srcCore = srcCoresHighestPrioThreads[index];
@@ -183,8 +183,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
if (src != null)
{
- //Run the second thread on the queue on the source core,
- //move the first one to the current core.
+ // Run the second thread on the queue on the source core,
+ // move the first one to the current core.
KThread origSelectedCoreSrc = CoreContexts[srcCore].SelectedThread;
CoreContexts[srcCore].SelectThread(src);
diff --git a/Ryujinx.HLE/HOS/Kernel/Threading/KSynchronization.cs b/Ryujinx.HLE/HOS/Kernel/Threading/KSynchronization.cs
index 327b0418..865551a2 100644
--- a/Ryujinx.HLE/HOS/Kernel/Threading/KSynchronization.cs
+++ b/Ryujinx.HLE/HOS/Kernel/Threading/KSynchronization.cs
@@ -20,7 +20,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
_system.CriticalSection.Enter();
- //Check if objects are already signaled before waiting.
+ // Check if objects are already signaled before waiting.
for (int index = 0; index < syncObjs.Length; index++)
{
if (!syncObjs[index].IsSignaled())
diff --git a/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs b/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs
index ebde34ba..50c71ea9 100644
--- a/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs
+++ b/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs
@@ -276,7 +276,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
public void Exit()
{
- //TODO: Debug event.
+ // TODO: Debug event.
if (Owner != null)
{
@@ -352,7 +352,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
if (DynamicPriority < KScheduler.PrioritiesCount)
{
- //Move current thread to the end of the queue.
+ // Move current thread to the end of the queue.
_schedulingData.Reschedule(DynamicPriority, CurrentCore, this);
}
@@ -383,7 +383,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
if (DynamicPriority < KScheduler.PrioritiesCount)
{
- //Move current thread to the end of the queue.
+ // Move current thread to the end of the queue.
_schedulingData.Reschedule(prio, core, this);
Func<KThread, bool> predicate = x => x.DynamicPriority == prio;
@@ -407,8 +407,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
}
}
- //If the candidate was scheduled after the current thread, then it's not worth it,
- //unless the priority is higher than the current one.
+ // If the candidate was scheduled after the current thread, then it's not worth it,
+ // unless the priority is higher than the current one.
if (nextThreadOnCurrentQueue.LastScheduledTime >= thread.LastScheduledTime ||
nextThreadOnCurrentQueue.DynamicPriority < thread.DynamicPriority)
{
@@ -524,7 +524,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
{
if (pause)
{
- //Pause, the force pause flag should be clear (thread is NOT paused).
+ // Pause, the force pause flag should be clear (thread is NOT paused).
if ((_forcePauseFlags & ThreadSchedState.ThreadPauseFlag) == 0)
{
_forcePauseFlags |= ThreadSchedState.ThreadPauseFlag;
@@ -538,7 +538,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
}
else
{
- //Unpause, the force pause flag should be set (thread is paused).
+ // Unpause, the force pause flag should be set (thread is paused).
if ((_forcePauseFlags & ThreadSchedState.ThreadPauseFlag) != 0)
{
ThreadSchedState oldForcePauseFlags = _forcePauseFlags;
@@ -604,7 +604,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
bool useOverride = _affinityOverrideCount != 0;
- //The value -3 is "do not change the preferred core".
+ // The value -3 is "do not change the preferred core".
if (newCore == -3)
{
newCore = useOverride ? _preferredCoreOverride : PreferredCore;
@@ -766,7 +766,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
do
{
- //Skip all threads that are not waiting for this mutex.
+ // Skip all threads that are not waiting for this mutex.
while (currentNode != null && currentNode.Value.MutexAddress != mutexAddress)
{
currentNode = currentNode.Next;
@@ -785,12 +785,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
if (newMutexOwner != null)
{
- //New owner was already selected, re-insert on new owner list.
+ // New owner was already selected, re-insert on new owner list.
newMutexOwner.AddToMutexWaitersList(currentNode.Value);
}
else
{
- //New owner not selected yet, use current thread.
+ // New owner not selected yet, use current thread.
newMutexOwner = currentNode.Value;
}
@@ -812,9 +812,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
private void UpdatePriorityInheritance()
{
- //If any of the threads waiting for the mutex has
- //higher priority than the current thread, then
- //the current thread inherits that priority.
+ // If any of the threads waiting for the mutex has
+ // higher priority than the current thread, then
+ // the current thread inherits that priority.
int highestPriority = BasePriority;
if (_mutexWaiters.First != null)
@@ -837,7 +837,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
if (MutexOwner != null)
{
- //Remove and re-insert to ensure proper sorting based on new priority.
+ // Remove and re-insert to ensure proper sorting based on new priority.
MutexOwner._mutexWaiters.Remove(_mutexWaiterNode);
MutexOwner.AddToMutexWaitersList(this);
@@ -877,7 +877,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
if (oldFlags == ThreadSchedState.Running)
{
- //Was running, now it's stopped.
+ // Was running, now it's stopped.
if (CurrentCore >= 0)
{
_schedulingData.Unschedule(DynamicPriority, CurrentCore, this);
@@ -893,7 +893,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
}
else if (SchedFlags == ThreadSchedState.Running)
{
- //Was stopped, now it's running.
+ // Was stopped, now it's running.
if (CurrentCore >= 0)
{
_schedulingData.Schedule(DynamicPriority, CurrentCore, this);
@@ -918,7 +918,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
return;
}
- //Remove thread from the old priority queues.
+ // Remove thread from the old priority queues.
if (CurrentCore >= 0)
{
_schedulingData.Unschedule(oldPriority, CurrentCore, this);
@@ -932,7 +932,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
}
}
- //Add thread to the new priority queues.
+ // Add thread to the new priority queues.
KThread currentThread = _scheduler.GetCurrentThread();
if (CurrentCore >= 0)
@@ -965,7 +965,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
return;
}
- //Remove thread from the old priority queues.
+ // Remove thread from the old priority queues.
for (int core = 0; core < KScheduler.CpuCoresCount; core++)
{
if (((oldAffinityMask >> core) & 1) != 0)
@@ -981,7 +981,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
}
}
- //Add thread to the new priority queues.
+ // Add thread to the new priority queues.
for (int core = 0; core < KScheduler.CpuCoresCount; core++)
{
if (((AffinityMask >> core) & 1) != 0)
@@ -1069,7 +1069,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
System.CriticalSection.Enter();
- //Wake up all threads that may be waiting for a mutex being held by this thread.
+ // Wake up all threads that may be waiting for a mutex being held by this thread.
foreach (KThread thread in _mutexWaiters)
{
thread.MutexOwner = null;