summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/scheduler.cpp
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-11-18 23:44:19 -0500
committerGravatar Zach Hilman2018-11-18 23:44:19 -0500
commit409dcf0e0aecfdb676fd3b64223a25e47c1b1c1a (patch)
treeccb9eae7c7e8b93760f3087fb6e67a13cbb24f2c /src/core/hle/kernel/scheduler.cpp
parentMerge pull request #1717 from FreddyFunk/swizzle-gob (diff)
downloadyuzu-409dcf0e0aecfdb676fd3b64223a25e47c1b1c1a.tar.gz
yuzu-409dcf0e0aecfdb676fd3b64223a25e47c1b1c1a.tar.xz
yuzu-409dcf0e0aecfdb676fd3b64223a25e47c1b1c1a.zip
svc: Implement yield types 0 and -1
Diffstat (limited to 'src/core/hle/kernel/scheduler.cpp')
-rw-r--r--src/core/hle/kernel/scheduler.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/core/hle/kernel/scheduler.cpp b/src/core/hle/kernel/scheduler.cpp
index 5a5f4cef1..fb5e14950 100644
--- a/src/core/hle/kernel/scheduler.cpp
+++ b/src/core/hle/kernel/scheduler.cpp
@@ -169,6 +169,16 @@ void Scheduler::UnscheduleThread(Thread* thread, u32 priority) {
169 ready_queue.remove(priority, thread); 169 ready_queue.remove(priority, thread);
170} 170}
171 171
172void Scheduler::RescheduleThread(Thread* thread, u32 priority) {
173 std::lock_guard<std::mutex> lock(scheduler_mutex);
174
175 // Thread is not in queue
176 ASSERT(ready_queue.contains(thread) != -1);
177
178 ready_queue.remove(priority, thread);
179 ready_queue.push_back(priority, thread);
180}
181
172void Scheduler::SetThreadPriority(Thread* thread, u32 priority) { 182void Scheduler::SetThreadPriority(Thread* thread, u32 priority) {
173 std::lock_guard<std::mutex> lock(scheduler_mutex); 183 std::lock_guard<std::mutex> lock(scheduler_mutex);
174 184
@@ -179,4 +189,12 @@ void Scheduler::SetThreadPriority(Thread* thread, u32 priority) {
179 ready_queue.prepare(priority); 189 ready_queue.prepare(priority);
180} 190}
181 191
192Thread* Scheduler::GetNextSuggestedThread(u32 core) {
193 std::lock_guard<std::mutex> lock(scheduler_mutex);
194
195 const auto mask = 1 << core;
196 return ready_queue.get_first_filter(
197 [&mask](Thread* thread) { return (thread->GetAffinityMask() & mask) != 0; });
198}
199
182} // namespace Kernel 200} // namespace Kernel