kernel: Fix svcWaitSynch to always acquire requested wait objects.

This commit is contained in:
bunnei 2015-06-07 23:39:37 -04:00
parent f1ff0fbf07
commit 71e8822d23
9 changed files with 68 additions and 113 deletions

View file

@ -32,27 +32,13 @@ void WaitObject::RemoveWaitingThread(Thread* thread) {
waiting_threads.erase(itr);
}
SharedPtr<Thread> WaitObject::WakeupNextThread() {
if (waiting_threads.empty())
return nullptr;
auto next_thread = std::move(waiting_threads.front());
waiting_threads.erase(waiting_threads.begin());
next_thread->ReleaseWaitObject(this);
return next_thread;
}
void WaitObject::WakeupAllWaitingThreads() {
auto waiting_threads_copy = waiting_threads;
for (auto thread : waiting_threads)
thread->ResumeFromWait();
// We use a copy because ReleaseWaitObject will remove the thread from this object's
// waiting_threads list
for (auto thread : waiting_threads_copy)
thread->ReleaseWaitObject(this);
waiting_threads.clear();
ASSERT_MSG(waiting_threads.empty(), "failed to awaken all waiting threads!");
HLE::Reschedule(__func__);
}
HandleTable::HandleTable() {