summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.cpp
diff options
context:
space:
mode:
authorGravatar balika0112018-10-05 14:51:16 -0400
committerGravatar Lioncash2018-10-05 14:53:01 -0400
commit1a5d6de0d46371b74828a2582506f1b3b2362589 (patch)
tree4bbb722ae36f032c031018bf8650bcc3f2cd8faf /src/core/hle/kernel/thread.cpp
parentMerge pull request #1439 from lioncash/thread (diff)
downloadyuzu-1a5d6de0d46371b74828a2582506f1b3b2362589.tar.gz
yuzu-1a5d6de0d46371b74828a2582506f1b3b2362589.tar.xz
yuzu-1a5d6de0d46371b74828a2582506f1b3b2362589.zip
thread: Make the scheduler pointer a regular pointer
Conceptually, it doesn't make sense for a thread to be able to persist the lifetime of a scheduler. A scheduler should be taking care of the threads; the threads should not be taking care of the scheduler. If the threads outlive the scheduler (or we simply don't actually terminate/shutdown the threads), then it should be considered a bug that we need to fix. Attributing this to balika011, as they opened #1317 to attempt to fix this in a similar way, but my refactoring of the kernel code caused quite a few conflicts.
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
-rw-r--r--src/core/hle/kernel/thread.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 354043c53..8e514cf9a 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -169,7 +169,7 @@ void Thread::ResumeFromWait() {
169 next_scheduler->ScheduleThread(this, current_priority); 169 next_scheduler->ScheduleThread(this, current_priority);
170 170
171 // Change thread's scheduler 171 // Change thread's scheduler
172 scheduler = next_scheduler; 172 scheduler = next_scheduler.get();
173 173
174 Core::System::GetInstance().CpuCore(processor_id).PrepareReschedule(); 174 Core::System::GetInstance().CpuCore(processor_id).PrepareReschedule();
175} 175}
@@ -233,7 +233,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(KernelCore& kernel, std::string name
233 thread->name = std::move(name); 233 thread->name = std::move(name);
234 thread->callback_handle = kernel.ThreadWakeupCallbackHandleTable().Create(thread).Unwrap(); 234 thread->callback_handle = kernel.ThreadWakeupCallbackHandleTable().Create(thread).Unwrap();
235 thread->owner_process = owner_process; 235 thread->owner_process = owner_process;
236 thread->scheduler = Core::System::GetInstance().Scheduler(processor_id); 236 thread->scheduler = Core::System::GetInstance().Scheduler(processor_id).get();
237 thread->scheduler->AddThread(thread, priority); 237 thread->scheduler->AddThread(thread, priority);
238 thread->tls_address = thread->owner_process->MarkNextAvailableTLSSlotAsUsed(*thread); 238 thread->tls_address = thread->owner_process->MarkNextAvailableTLSSlotAsUsed(*thread);
239 239
@@ -400,7 +400,7 @@ void Thread::ChangeCore(u32 core, u64 mask) {
400 next_scheduler->ScheduleThread(this, current_priority); 400 next_scheduler->ScheduleThread(this, current_priority);
401 401
402 // Change thread's scheduler 402 // Change thread's scheduler
403 scheduler = next_scheduler; 403 scheduler = next_scheduler.get();
404 404
405 Core::System::GetInstance().CpuCore(processor_id).PrepareReschedule(); 405 Core::System::GetInstance().CpuCore(processor_id).PrepareReschedule();
406} 406}