kern: fix missing scheduler updates in KLightLock/Exception, fix RequestScheduleOnInterrupt

This commit is contained in:
Michael Scire 2020-08-02 23:06:29 -07:00 committed by SciresM
parent 920b017677
commit e1bd6fb874
9 changed files with 64 additions and 56 deletions

View file

@ -737,6 +737,8 @@ namespace ams::kern {
this->exception_thread->AddWaiter(cur_thread);
if (cur_thread->GetState() == KThread::ThreadState_Runnable) {
cur_thread->SetState(KThread::ThreadState_Waiting);
} else {
KScheduler::SetSchedulerUpdateNeeded();
}
}
/* Remove the thread as a waiter from the lock owner. */
@ -745,6 +747,7 @@ namespace ams::kern {
KThread *owner_thread = cur_thread->GetLockOwner();
if (owner_thread != nullptr) {
owner_thread->RemoveWaiter(cur_thread);
KScheduler::SetSchedulerUpdateNeeded();
}
}
}
@ -769,6 +772,8 @@ namespace ams::kern {
if (next != nullptr) {
if (next->GetState() == KThread::ThreadState_Waiting) {
next->SetState(KThread::ThreadState_Runnable);
} else {
KScheduler::SetSchedulerUpdateNeeded();
}
}
@ -980,6 +985,36 @@ namespace ams::kern {
return ResultSuccess();
}
void KProcess::PinCurrentThread() {
MESOSPHERE_ASSERT(KScheduler::IsSchedulerLockedByCurrentThread());
/* Get the current thread. */
const s32 core_id = GetCurrentCoreId();
KThread *cur_thread = GetCurrentThreadPointer();
/* Pin it. */
this->PinThread(core_id, cur_thread);
cur_thread->Pin();
/* An update is needed. */
KScheduler::SetSchedulerUpdateNeeded();
}
void KProcess::UnpinCurrentThread() {
MESOSPHERE_ASSERT(KScheduler::IsSchedulerLockedByCurrentThread());
/* Get the current thread. */
const s32 core_id = GetCurrentCoreId();
KThread *cur_thread = GetCurrentThreadPointer();
/* Unpin it. */
cur_thread->Unpin();
this->UnpinThread(core_id, cur_thread);
/* An update is needed. */
KScheduler::SetSchedulerUpdateNeeded();
}
Result KProcess::GetThreadList(s32 *out_num_threads, ams::kern::svc::KUserPointer<u64 *> out_thread_ids, s32 max_out_count) {
/* Lock the list. */
KScopedLightLock lk(this->list_lock);