summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/process.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/process.cpp')
-rw-r--r--src/core/hle/kernel/process.cpp29
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 @@
7#include "common/assert.h" 7#include "common/assert.h"
8#include "common/common_funcs.h" 8#include "common/common_funcs.h"
9#include "common/logging/log.h" 9#include "common/logging/log.h"
10#include "core/core.h"
10#include "core/hle/kernel/errors.h" 11#include "core/hle/kernel/errors.h"
11#include "core/hle/kernel/kernel.h" 12#include "core/hle/kernel/kernel.h"
12#include "core/hle/kernel/process.h" 13#include "core/hle/kernel/process.h"
13#include "core/hle/kernel/resource_limit.h" 14#include "core/hle/kernel/resource_limit.h"
15#include "core/hle/kernel/scheduler.h"
14#include "core/hle/kernel/thread.h" 16#include "core/hle/kernel/thread.h"
15#include "core/hle/kernel/vm_manager.h" 17#include "core/hle/kernel/vm_manager.h"
16#include "core/memory.h" 18#include "core/memory.h"
@@ -128,6 +130,33 @@ void Process::Run(VAddr entry_point, s32 main_thread_priority, u32 stack_size) {
128 Kernel::SetupMainThread(kernel, entry_point, main_thread_priority, *this); 130 Kernel::SetupMainThread(kernel, entry_point, main_thread_priority, *this);
129} 131}
130 132
133void Process::PrepareForTermination() {
134 status = ProcessStatus::Exited;
135
136 const auto stop_threads = [this](const std::vector<SharedPtr<Thread>>& thread_list) {
137 for (auto& thread : thread_list) {
138 if (thread->owner_process != this)
139 continue;
140
141 if (thread == GetCurrentThread())
142 continue;
143
144 // TODO(Subv): When are the other running/ready threads terminated?
145 ASSERT_MSG(thread->status == ThreadStatus::WaitSynchAny ||
146 thread->status == ThreadStatus::WaitSynchAll,
147 "Exiting processes with non-waiting threads is currently unimplemented");
148
149 thread->Stop();
150 }
151 };
152
153 auto& system = Core::System::GetInstance();
154 stop_threads(system.Scheduler(0)->GetThreadList());
155 stop_threads(system.Scheduler(1)->GetThreadList());
156 stop_threads(system.Scheduler(2)->GetThreadList());
157 stop_threads(system.Scheduler(3)->GetThreadList());
158}
159
131/** 160/**
132 * Finds a free location for the TLS section of a thread. 161 * Finds a free location for the TLS section of a thread.
133 * @param tls_slots The TLS page array of the thread's owner process. 162 * @param tls_slots The TLS page array of the thread's owner process.