diff options
author | Lioncash <mathew1800@gmail.com> | 2018-09-21 08:06:47 +0200 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2018-09-21 12:07:41 +0200 |
commit | 48b2eda492c064eeaf5af3716a9855b082eb2df7 (patch) | |
tree | 2a86155b190bfa5326f83444dab3f2b6c5c3da47 /src/core/hle/kernel/process.cpp | |
parent | thread/process: Move TLS slot marking/freeing to the process class (diff) | |
download | yuzu-48b2eda492c064eeaf5af3716a9855b082eb2df7.tar yuzu-48b2eda492c064eeaf5af3716a9855b082eb2df7.tar.gz yuzu-48b2eda492c064eeaf5af3716a9855b082eb2df7.tar.bz2 yuzu-48b2eda492c064eeaf5af3716a9855b082eb2df7.tar.lz yuzu-48b2eda492c064eeaf5af3716a9855b082eb2df7.tar.xz yuzu-48b2eda492c064eeaf5af3716a9855b082eb2df7.tar.zst yuzu-48b2eda492c064eeaf5af3716a9855b082eb2df7.zip |
Diffstat (limited to 'src/core/hle/kernel/process.cpp')
-rw-r--r-- | src/core/hle/kernel/process.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 0c8ea94fc..121f741fd 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp @@ -7,10 +7,12 @@ #include "common/assert.h" #include "common/common_funcs.h" #include "common/logging/log.h" +#include "core/core.h" #include "core/hle/kernel/errors.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/process.h" #include "core/hle/kernel/resource_limit.h" +#include "core/hle/kernel/scheduler.h" #include "core/hle/kernel/thread.h" #include "core/hle/kernel/vm_manager.h" #include "core/memory.h" @@ -128,6 +130,33 @@ void Process::Run(VAddr entry_point, s32 main_thread_priority, u32 stack_size) { Kernel::SetupMainThread(kernel, entry_point, main_thread_priority, *this); } +void Process::PrepareForTermination() { + status = ProcessStatus::Exited; + + const auto stop_threads = [this](const std::vector<SharedPtr<Thread>>& thread_list) { + for (auto& thread : thread_list) { + if (thread->owner_process != this) + continue; + + if (thread == GetCurrentThread()) + continue; + + // TODO(Subv): When are the other running/ready threads terminated? + ASSERT_MSG(thread->status == ThreadStatus::WaitSynchAny || + thread->status == ThreadStatus::WaitSynchAll, + "Exiting processes with non-waiting threads is currently unimplemented"); + + thread->Stop(); + } + }; + + auto& system = Core::System::GetInstance(); + stop_threads(system.Scheduler(0)->GetThreadList()); + stop_threads(system.Scheduler(1)->GetThreadList()); + stop_threads(system.Scheduler(2)->GetThreadList()); + stop_threads(system.Scheduler(3)->GetThreadList()); +} + /** * Finds a free location for the TLS section of a thread. * @param tls_slots The TLS page array of the thread's owner process. |