summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.cpp
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2019-10-12 08:02:34 -0400
committerGravatar FernandoS272019-10-15 11:55:23 -0400
commitb3c1deba494d78158ea6764802880b249fe64416 (patch)
tree4269df68a0877b18bcb0544d56df5abc895859d6 /src/core/hle/kernel/thread.cpp
parentKernelSVC: Assert that condition variable address is aligned to 4 bytes. (diff)
downloadyuzu-b3c1deba494d78158ea6764802880b249fe64416.tar.gz
yuzu-b3c1deba494d78158ea6764802880b249fe64416.tar.xz
yuzu-b3c1deba494d78158ea6764802880b249fe64416.zip
Kernel_Thread: Eliminate most global accessors.
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
-rw-r--r--src/core/hle/kernel/thread.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 0871a2f00..7208bbb11 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -41,8 +41,8 @@ Thread::~Thread() = default;
41 41
42void Thread::Stop() { 42void Thread::Stop() {
43 // Cancel any outstanding wakeup events for this thread 43 // Cancel any outstanding wakeup events for this thread
44 Core::System::GetInstance().CoreTiming().UnscheduleEvent(kernel.ThreadWakeupCallbackEventType(), 44 kernel.System().CoreTiming().UnscheduleEvent(kernel.ThreadWakeupCallbackEventType(),
45 callback_handle); 45 callback_handle);
46 kernel.ThreadWakeupCallbackHandleTable().Close(callback_handle); 46 kernel.ThreadWakeupCallbackHandleTable().Close(callback_handle);
47 callback_handle = 0; 47 callback_handle = 0;
48 SetStatus(ThreadStatus::Dead); 48 SetStatus(ThreadStatus::Dead);
@@ -68,13 +68,13 @@ void Thread::WakeAfterDelay(s64 nanoseconds) {
68 // This function might be called from any thread so we have to be cautious and use the 68 // This function might be called from any thread so we have to be cautious and use the
69 // thread-safe version of ScheduleEvent. 69 // thread-safe version of ScheduleEvent.
70 const s64 cycles = Core::Timing::nsToCycles(std::chrono::nanoseconds{nanoseconds}); 70 const s64 cycles = Core::Timing::nsToCycles(std::chrono::nanoseconds{nanoseconds});
71 Core::System::GetInstance().CoreTiming().ScheduleEvent( 71 kernel.System().CoreTiming().ScheduleEvent(cycles, kernel.ThreadWakeupCallbackEventType(),
72 cycles, kernel.ThreadWakeupCallbackEventType(), callback_handle); 72 callback_handle);
73} 73}
74 74
75void Thread::CancelWakeupTimer() { 75void Thread::CancelWakeupTimer() {
76 Core::System::GetInstance().CoreTiming().UnscheduleEvent(kernel.ThreadWakeupCallbackEventType(), 76 kernel.System().CoreTiming().UnscheduleEvent(kernel.ThreadWakeupCallbackEventType(),
77 callback_handle); 77 callback_handle);
78} 78}
79 79
80static std::optional<s32> GetNextProcessorId(u64 mask) { 80static std::optional<s32> GetNextProcessorId(u64 mask) {
@@ -176,7 +176,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(KernelCore& kernel, std::string name
176 return ResultCode(-1); 176 return ResultCode(-1);
177 } 177 }
178 178
179 auto& system = Core::System::GetInstance(); 179 auto& system = kernel.System();
180 SharedPtr<Thread> thread(new Thread(kernel)); 180 SharedPtr<Thread> thread(new Thread(kernel));
181 181
182 thread->thread_id = kernel.CreateNewThreadID(); 182 thread->thread_id = kernel.CreateNewThreadID();
@@ -258,7 +258,7 @@ void Thread::SetStatus(ThreadStatus new_status) {
258 } 258 }
259 259
260 if (status == ThreadStatus::Running) { 260 if (status == ThreadStatus::Running) {
261 last_running_ticks = Core::System::GetInstance().CoreTiming().GetTicks(); 261 last_running_ticks = kernel.System().CoreTiming().GetTicks();
262 } 262 }
263 263
264 status = new_status; 264 status = new_status;
@@ -356,7 +356,7 @@ void Thread::SetActivity(ThreadActivity value) {
356 // Set status if not waiting 356 // Set status if not waiting
357 if (status == ThreadStatus::Ready || status == ThreadStatus::Running) { 357 if (status == ThreadStatus::Ready || status == ThreadStatus::Running) {
358 SetStatus(ThreadStatus::Paused); 358 SetStatus(ThreadStatus::Paused);
359 Core::System::GetInstance().CpuCore(processor_id).PrepareReschedule(); 359 kernel.System().CpuCore(processor_id).PrepareReschedule();
360 } 360 }
361 } else if (status == ThreadStatus::Paused) { 361 } else if (status == ThreadStatus::Paused) {
362 // Ready to reschedule 362 // Ready to reschedule
@@ -476,7 +476,7 @@ void Thread::AdjustSchedulingOnPriority(u32 old_priority) {
476 if (GetSchedulingStatus() != ThreadSchedStatus::Runnable) { 476 if (GetSchedulingStatus() != ThreadSchedStatus::Runnable) {
477 return; 477 return;
478 } 478 }
479 auto& scheduler = Core::System::GetInstance().GlobalScheduler(); 479 auto& scheduler = kernel.System().GlobalScheduler();
480 if (processor_id >= 0) { 480 if (processor_id >= 0) {
481 scheduler.Unschedule(old_priority, processor_id, this); 481 scheduler.Unschedule(old_priority, processor_id, this);
482 } 482 }
@@ -508,7 +508,7 @@ void Thread::AdjustSchedulingOnPriority(u32 old_priority) {
508} 508}
509 509
510void Thread::AdjustSchedulingOnAffinity(u64 old_affinity_mask, s32 old_core) { 510void Thread::AdjustSchedulingOnAffinity(u64 old_affinity_mask, s32 old_core) {
511 auto& scheduler = Core::System::GetInstance().GlobalScheduler(); 511 auto& scheduler = kernel.System().GlobalScheduler();
512 if (GetSchedulingStatus() != ThreadSchedStatus::Runnable || 512 if (GetSchedulingStatus() != ThreadSchedStatus::Runnable ||
513 current_priority >= THREADPRIO_COUNT) { 513 current_priority >= THREADPRIO_COUNT) {
514 return; 514 return;