summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2017-01-06 00:40:39 -0500
committerGravatar GitHub2017-01-06 00:40:39 -0500
commit1c792389e677ac458696af1903812b5cdc400eab (patch)
treedf7a11197a1d7afd3e4f9fafd207be4ad70b6ac1 /src/core/hle/kernel/thread.cpp
parentMerge pull request #2409 from Subv/unused_funcs (diff)
parentKernel: Removed the priority boost code for starved threads. (diff)
downloadyuzu-1c792389e677ac458696af1903812b5cdc400eab.tar.gz
yuzu-1c792389e677ac458696af1903812b5cdc400eab.tar.xz
yuzu-1c792389e677ac458696af1903812b5cdc400eab.zip
Merge pull request #2408 from Subv/priority_boosting
Kernel: Removed the priority boost code for starved threads.
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
-rw-r--r--src/core/hle/kernel/thread.cpp27
1 files changed, 0 insertions, 27 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 7b351ed5e..cb9a93ee4 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -141,28 +141,6 @@ void ArbitrateAllThreads(u32 address) {
141 } 141 }
142} 142}
143 143
144/// Boost low priority threads (temporarily) that have been starved
145static void PriorityBoostStarvedThreads() {
146 u64 current_ticks = CoreTiming::GetTicks();
147
148 for (auto& thread : thread_list) {
149 // TODO(bunnei): Threads that have been waiting to be scheduled for `boost_ticks` (or
150 // longer) will have their priority temporarily adjusted to 1 higher than the highest
151 // priority thread to prevent thread starvation. This general behavior has been verified
152 // on hardware. However, this is almost certainly not perfect, and the real CTR OS scheduler
153 // should probably be reversed to verify this.
154
155 const u64 boost_timeout = 2000000; // Boost threads that have been ready for > this long
156
157 u64 delta = current_ticks - thread->last_running_ticks;
158
159 if (thread->status == THREADSTATUS_READY && delta > boost_timeout) {
160 const s32 priority = std::max(ready_queue.get_first()->current_priority - 1, 0);
161 thread->BoostPriority(priority);
162 }
163 }
164}
165
166/** 144/**
167 * Switches the CPU's active thread context to that of the specified thread 145 * Switches the CPU's active thread context to that of the specified thread
168 * @param new_thread The thread to switch to 146 * @param new_thread The thread to switch to
@@ -196,9 +174,6 @@ static void SwitchContext(Thread* new_thread) {
196 ready_queue.remove(new_thread->current_priority, new_thread); 174 ready_queue.remove(new_thread->current_priority, new_thread);
197 new_thread->status = THREADSTATUS_RUNNING; 175 new_thread->status = THREADSTATUS_RUNNING;
198 176
199 // Restores thread to its nominal priority if it has been temporarily changed
200 new_thread->current_priority = new_thread->nominal_priority;
201
202 Core::CPU().LoadContext(new_thread->context); 177 Core::CPU().LoadContext(new_thread->context);
203 Core::CPU().SetCP15Register(CP15_THREAD_URO, new_thread->GetTLSAddress()); 178 Core::CPU().SetCP15Register(CP15_THREAD_URO, new_thread->GetTLSAddress());
204 } else { 179 } else {
@@ -534,8 +509,6 @@ SharedPtr<Thread> SetupMainThread(u32 entry_point, s32 priority) {
534} 509}
535 510
536void Reschedule() { 511void Reschedule() {
537 PriorityBoostStarvedThreads();
538
539 Thread* cur = GetCurrentThread(); 512 Thread* cur = GetCurrentThread();
540 Thread* next = PopNextReadyThread(); 513 Thread* next = PopNextReadyThread();
541 514