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

@ -147,6 +147,10 @@ namespace ams::kern {
return this->is_suspended;
}
bool EnterUserException();
bool LeaveUserException();
bool ReleaseUserException(KThread *thread);
KThread *GetPreemptionStatePinnedThread(s32 core_id) const {
MESOSPHERE_ASSERT(0 <= core_id && core_id < static_cast<s32>(cpu::NumCores));
return this->pinned_threads[core_id];
@ -186,6 +190,14 @@ namespace ams::kern {
void IncrementThreadCount();
void DecrementThreadCount();
void ClearRunningThread(KThread *thread) {
for (size_t i = 0; i < util::size(this->running_threads); ++i) {
if (this->running_threads[i] == thread) {
this->running_threads[i] = nullptr;
}
}
}
void RegisterThread(KThread *thread);
void UnregisterThread(KThread *thread);

View file

@ -116,6 +116,8 @@ namespace ams::kern {
}
}
static NOINLINE void ClearPreviousThread(KThread *thread);
static NOINLINE void OnThreadStateChanged(KThread *thread, KThread::ThreadState old_state);
static NOINLINE void OnThreadPriorityChanged(KThread *thread, s32 old_priority);
static NOINLINE void OnThreadAffinityMaskChanged(KThread *thread, const KAffinityMask &old_affinity, s32 old_core);

View file

@ -268,6 +268,9 @@ namespace ams::kern {
ALWAYS_INLINE void AddWaiterImpl(KThread *thread);
ALWAYS_INLINE void RemoveWaiterImpl(KThread *thread);
ALWAYS_INLINE static void RestorePriority(KThread *thread);
void StartTermination();
void FinishTermination();
public:
constexpr u64 GetThreadId() const { return this->thread_id; }

View file

@ -94,6 +94,10 @@ namespace ams::kern {
static KThread &GetMainThread(s32 core_id);
static KThread &GetIdleThread(s32 core_id);
static ALWAYS_INLINE KCurrentContext &GetCurrentContext(s32 core_id) {
return GetCoreLocalContext(core_id).current;
}
static ALWAYS_INLINE KScheduler &GetScheduler() {
return GetCoreLocalContext().scheduler;
}