Merge pull request #8502 from liamwhite/end-wait

kernel: clean up waiting implementation
This commit is contained in:
liamwhite 2022-07-07 17:31:49 -04:00 committed by GitHub
commit 7e75593c20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View file

@ -161,7 +161,7 @@ bool KProcess::ReleaseUserException(KThread* thread) {
std::addressof(num_waiters), std::addressof(num_waiters),
reinterpret_cast<uintptr_t>(std::addressof(exception_thread))); reinterpret_cast<uintptr_t>(std::addressof(exception_thread)));
next != nullptr) { next != nullptr) {
next->SetState(ThreadState::Runnable); next->EndWait(ResultSuccess);
} }
KScheduler::SetSchedulerUpdateNeeded(kernel); KScheduler::SetSchedulerUpdateNeeded(kernel);

View file

@ -480,9 +480,7 @@ void KThread::Unpin() {
// Resume any threads that began waiting on us while we were pinned. // Resume any threads that began waiting on us while we were pinned.
for (auto it = pinned_waiter_list.begin(); it != pinned_waiter_list.end(); ++it) { for (auto it = pinned_waiter_list.begin(); it != pinned_waiter_list.end(); ++it) {
if (it->GetState() == ThreadState::Waiting) { it->EndWait(ResultSuccess);
it->SetState(ThreadState::Runnable);
}
} }
} }
@ -877,6 +875,7 @@ void KThread::AddWaiterImpl(KThread* thread) {
// Keep track of how many kernel waiters we have. // Keep track of how many kernel waiters we have.
if (IsKernelAddressKey(thread->GetAddressKey())) { if (IsKernelAddressKey(thread->GetAddressKey())) {
ASSERT((num_kernel_waiters++) >= 0); ASSERT((num_kernel_waiters++) >= 0);
KScheduler::SetSchedulerUpdateNeeded(kernel);
} }
// Insert the waiter. // Insert the waiter.
@ -890,6 +889,7 @@ void KThread::RemoveWaiterImpl(KThread* thread) {
// Keep track of how many kernel waiters we have. // Keep track of how many kernel waiters we have.
if (IsKernelAddressKey(thread->GetAddressKey())) { if (IsKernelAddressKey(thread->GetAddressKey())) {
ASSERT((num_kernel_waiters--) > 0); ASSERT((num_kernel_waiters--) > 0);
KScheduler::SetSchedulerUpdateNeeded(kernel);
} }
// Remove the waiter. // Remove the waiter.
@ -965,6 +965,7 @@ KThread* KThread::RemoveWaiterByKey(s32* out_num_waiters, VAddr key) {
// Keep track of how many kernel waiters we have. // Keep track of how many kernel waiters we have.
if (IsKernelAddressKey(thread->GetAddressKey())) { if (IsKernelAddressKey(thread->GetAddressKey())) {
ASSERT((num_kernel_waiters--) > 0); ASSERT((num_kernel_waiters--) > 0);
KScheduler::SetSchedulerUpdateNeeded(kernel);
} }
it = waiter_list.erase(it); it = waiter_list.erase(it);