svc: Implement yield types 0 and -1

This commit is contained in:
Zach Hilman 2018-11-18 23:44:19 -05:00
parent f02b125ac8
commit 409dcf0e0a
6 changed files with 130 additions and 2 deletions

View file

@ -169,6 +169,16 @@ void Scheduler::UnscheduleThread(Thread* thread, u32 priority) {
ready_queue.remove(priority, thread);
}
void Scheduler::RescheduleThread(Thread* thread, u32 priority) {
std::lock_guard<std::mutex> lock(scheduler_mutex);
// Thread is not in queue
ASSERT(ready_queue.contains(thread) != -1);
ready_queue.remove(priority, thread);
ready_queue.push_back(priority, thread);
}
void Scheduler::SetThreadPriority(Thread* thread, u32 priority) {
std::lock_guard<std::mutex> lock(scheduler_mutex);
@ -179,4 +189,12 @@ void Scheduler::SetThreadPriority(Thread* thread, u32 priority) {
ready_queue.prepare(priority);
}
Thread* Scheduler::GetNextSuggestedThread(u32 core) {
std::lock_guard<std::mutex> lock(scheduler_mutex);
const auto mask = 1 << core;
return ready_queue.get_first_filter(
[&mask](Thread* thread) { return (thread->GetAffinityMask() & mask) != 0; });
}
} // namespace Kernel