summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2019-09-10 15:26:24 -0400
committerGravatar FernandoS272019-10-15 11:55:15 -0400
commit2d382de6fa79123fae7842246588651ee99b15e2 (patch)
treec260840e12ccbb1181117403c7e463b55bfa0e5f
parentKernel: Initial implementation of thread preemption. (diff)
downloadyuzu-2d382de6fa79123fae7842246588651ee99b15e2.tar.gz
yuzu-2d382de6fa79123fae7842246588651ee99b15e2.tar.xz
yuzu-2d382de6fa79123fae7842246588651ee99b15e2.zip
Scheduler: Corrections to YieldAndBalanceLoad and Yield bombing protection.
-rw-r--r--src/core/hle/kernel/scheduler.cpp14
-rw-r--r--src/core/hle/kernel/scheduler.h2
2 files changed, 8 insertions, 8 deletions
diff --git a/src/core/hle/kernel/scheduler.cpp b/src/core/hle/kernel/scheduler.cpp
index 0d45307cd..78463cef5 100644
--- a/src/core/hle/kernel/scheduler.cpp
+++ b/src/core/hle/kernel/scheduler.cpp
@@ -165,12 +165,12 @@ bool GlobalScheduler::YieldThreadAndBalanceLoad(Thread* yielding_thread) {
165 continue; 165 continue;
166 } 166 }
167 } 167 }
168 if (next_thread->GetLastRunningTicks() >= thread->GetLastRunningTicks() || 168 }
169 next_thread->GetPriority() < thread->GetPriority()) { 169 if (next_thread->GetLastRunningTicks() >= thread->GetLastRunningTicks() ||
170 if (thread->GetPriority() <= priority) { 170 next_thread->GetPriority() < thread->GetPriority()) {
171 winner = thread; 171 if (thread->GetPriority() <= priority) {
172 break; 172 winner = thread;
173 } 173 break;
174 } 174 }
175 } 175 }
176 } 176 }
@@ -240,7 +240,7 @@ bool GlobalScheduler::YieldThreadAndWaitForLoadBalancing(Thread* yielding_thread
240 240
241void GlobalScheduler::PreemptThreads() { 241void GlobalScheduler::PreemptThreads() {
242 for (std::size_t core_id = 0; core_id < NUM_CPU_CORES; core_id++) { 242 for (std::size_t core_id = 0; core_id < NUM_CPU_CORES; core_id++) {
243 const u64 priority = preemption_priorities[core_id]; 243 const u32 priority = preemption_priorities[core_id];
244 if (scheduled_queue[core_id].size(priority) > 1) { 244 if (scheduled_queue[core_id].size(priority) > 1) {
245 scheduled_queue[core_id].yield(priority); 245 scheduled_queue[core_id].yield(priority);
246 reselection_pending.store(true, std::memory_order_release); 246 reselection_pending.store(true, std::memory_order_release);
diff --git a/src/core/hle/kernel/scheduler.h b/src/core/hle/kernel/scheduler.h
index c13a368fd..408e20c88 100644
--- a/src/core/hle/kernel/scheduler.h
+++ b/src/core/hle/kernel/scheduler.h
@@ -155,7 +155,7 @@ private:
155 std::array<Common::MultiLevelQueue<Thread*, THREADPRIO_COUNT>, NUM_CPU_CORES> suggested_queue; 155 std::array<Common::MultiLevelQueue<Thread*, THREADPRIO_COUNT>, NUM_CPU_CORES> suggested_queue;
156 std::atomic<bool> reselection_pending; 156 std::atomic<bool> reselection_pending;
157 157
158 std::array<u64, NUM_CPU_CORES> preemption_priorities = {59, 59, 59, 62}; 158 std::array<u32, NUM_CPU_CORES> preemption_priorities = {59, 59, 59, 62};
159 159
160 /// Lists all thread ids that aren't deleted/etc. 160 /// Lists all thread ids that aren't deleted/etc.
161 std::vector<SharedPtr<Thread>> thread_list; 161 std::vector<SharedPtr<Thread>> thread_list;