summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/process.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2021-04-03 19:11:46 -0700
committerGravatar bunnei2021-05-05 16:40:50 -0700
commitda7e9553dea4b1eaefb71aca8642ccce7c7f50fb (patch)
tree3da10a60005ddcc4237900eb5e7473fe7b006152 /src/core/hle/kernel/process.cpp
parenthle: kernel: svc: Migrate GetThreadPriority, StartThread, and ExitThread. (diff)
downloadyuzu-da7e9553dea4b1eaefb71aca8642ccce7c7f50fb.tar.gz
yuzu-da7e9553dea4b1eaefb71aca8642ccce7c7f50fb.tar.xz
yuzu-da7e9553dea4b1eaefb71aca8642ccce7c7f50fb.zip
hle: kernel: Migrate more of KThread to KAutoObject.
Diffstat (limited to 'src/core/hle/kernel/process.cpp')
-rw-r--r--src/core/hle/kernel/process.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp
index e35deb8e2..796dca5ef 100644
--- a/src/core/hle/kernel/process.cpp
+++ b/src/core/hle/kernel/process.cpp
@@ -40,14 +40,15 @@ namespace {
40void SetupMainThread(Core::System& system, Process& owner_process, u32 priority, VAddr stack_top) { 40void SetupMainThread(Core::System& system, Process& owner_process, u32 priority, VAddr stack_top) {
41 const VAddr entry_point = owner_process.PageTable().GetCodeRegionStart(); 41 const VAddr entry_point = owner_process.PageTable().GetCodeRegionStart();
42 ASSERT(owner_process.GetResourceLimit()->Reserve(LimitableResource::Threads, 1)); 42 ASSERT(owner_process.GetResourceLimit()->Reserve(LimitableResource::Threads, 1));
43 auto thread_res =
44 KThread::CreateUserThread(system, ThreadType::User, "main", entry_point, priority, 0,
45 owner_process.GetIdealCoreId(), stack_top, &owner_process);
46 43
47 std::shared_ptr<KThread> thread = std::move(thread_res).Unwrap(); 44 KThread* thread = KThread::CreateWithKernel(system.Kernel());
45 ASSERT(KThread::InitializeUserThread(system, thread, entry_point, 0, stack_top, priority,
46 owner_process.GetIdealCoreId(), &owner_process)
47 .IsSuccess());
48 48
49 // Register 1 must be a handle to the main thread 49 // Register 1 must be a handle to the main thread
50 const Handle thread_handle = owner_process.GetHandleTable().Create(thread).Unwrap(); 50 Handle thread_handle{};
51 owner_process.GetHandleTable().Add(&thread_handle, thread);
51 thread->GetContext32().cpu_registers[0] = 0; 52 thread->GetContext32().cpu_registers[0] = 0;
52 thread->GetContext64().cpu_registers[0] = 0; 53 thread->GetContext64().cpu_registers[0] = 0;
53 thread->GetContext32().cpu_registers[1] = thread_handle; 54 thread->GetContext32().cpu_registers[1] = thread_handle;
@@ -337,12 +338,12 @@ void Process::Run(s32 main_thread_priority, u64 stack_size) {
337void Process::PrepareForTermination() { 338void Process::PrepareForTermination() {
338 ChangeStatus(ProcessStatus::Exiting); 339 ChangeStatus(ProcessStatus::Exiting);
339 340
340 const auto stop_threads = [this](const std::vector<std::shared_ptr<KThread>>& thread_list) { 341 const auto stop_threads = [this](const std::vector<KThread*>& thread_list) {
341 for (auto& thread : thread_list) { 342 for (auto& thread : thread_list) {
342 if (thread->GetOwnerProcess() != this) 343 if (thread->GetOwnerProcess() != this)
343 continue; 344 continue;
344 345
345 if (thread.get() == kernel.CurrentScheduler()->GetCurrentThread()) 346 if (thread == kernel.CurrentScheduler()->GetCurrentThread())
346 continue; 347 continue;
347 348
348 // TODO(Subv): When are the other running/ready threads terminated? 349 // TODO(Subv): When are the other running/ready threads terminated?