kern: mostly implement thread exit

This commit is contained in:
Michael Scire 2020-07-10 18:39:53 -07:00
parent c8f71007ec
commit 4a767c9082
8 changed files with 126 additions and 3 deletions

View file

@ -262,6 +262,16 @@ namespace ams::kern {
cpu::SwitchThreadLocalRegion(GetInteger(next_thread->GetThreadLocalRegionAddress()));
}
void KScheduler::ClearPreviousThread(KThread *thread) {
MESOSPHERE_ASSERT(IsSchedulerLockedByCurrentThread());
for (size_t i = 0; i < cpu::NumCores; ++i) {
std::atomic<KThread *> *prev_thread_ptr = reinterpret_cast<std::atomic<KThread *> *>(std::addressof(Kernel::GetScheduler(static_cast<s32>(i)).prev_thread));
static_assert(sizeof(*prev_thread_ptr) == sizeof(KThread *));
prev_thread_ptr->compare_exchange_weak(thread, nullptr);
}
}
void KScheduler::OnThreadStateChanged(KThread *thread, KThread::ThreadState old_state) {
MESOSPHERE_ASSERT(IsSchedulerLockedByCurrentThread());