summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
-rw-r--r--src/core/hle/kernel/thread.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 7881c2b90..6661e2130 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -43,7 +43,8 @@ Thread::~Thread() = default;
43 43
44void Thread::Stop() { 44void Thread::Stop() {
45 // Cancel any outstanding wakeup events for this thread 45 // Cancel any outstanding wakeup events for this thread
46 Core::Timing::UnscheduleEvent(kernel.ThreadWakeupCallbackEventType(), callback_handle); 46 Core::System::GetInstance().CoreTiming().UnscheduleEvent(kernel.ThreadWakeupCallbackEventType(),
47 callback_handle);
47 kernel.ThreadWakeupCallbackHandleTable().Close(callback_handle); 48 kernel.ThreadWakeupCallbackHandleTable().Close(callback_handle);
48 callback_handle = 0; 49 callback_handle = 0;
49 50
@@ -85,13 +86,14 @@ void Thread::WakeAfterDelay(s64 nanoseconds) {
85 86
86 // This function might be called from any thread so we have to be cautious and use the 87 // This function might be called from any thread so we have to be cautious and use the
87 // thread-safe version of ScheduleEvent. 88 // thread-safe version of ScheduleEvent.
88 Core::Timing::ScheduleEventThreadsafe(Core::Timing::nsToCycles(nanoseconds), 89 Core::System::GetInstance().CoreTiming().ScheduleEventThreadsafe(
89 kernel.ThreadWakeupCallbackEventType(), callback_handle); 90 Core::Timing::nsToCycles(nanoseconds), kernel.ThreadWakeupCallbackEventType(),
91 callback_handle);
90} 92}
91 93
92void Thread::CancelWakeupTimer() { 94void Thread::CancelWakeupTimer() {
93 Core::Timing::UnscheduleEventThreadsafe(kernel.ThreadWakeupCallbackEventType(), 95 Core::System::GetInstance().CoreTiming().UnscheduleEventThreadsafe(
94 callback_handle); 96 kernel.ThreadWakeupCallbackEventType(), callback_handle);
95} 97}
96 98
97static std::optional<s32> GetNextProcessorId(u64 mask) { 99static std::optional<s32> GetNextProcessorId(u64 mask) {
@@ -190,6 +192,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(KernelCore& kernel, std::string name
190 return ResultCode(-1); 192 return ResultCode(-1);
191 } 193 }
192 194
195 auto& system = Core::System::GetInstance();
193 SharedPtr<Thread> thread(new Thread(kernel)); 196 SharedPtr<Thread> thread(new Thread(kernel));
194 197
195 thread->thread_id = kernel.CreateNewThreadID(); 198 thread->thread_id = kernel.CreateNewThreadID();
@@ -198,7 +201,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(KernelCore& kernel, std::string name
198 thread->stack_top = stack_top; 201 thread->stack_top = stack_top;
199 thread->tpidr_el0 = 0; 202 thread->tpidr_el0 = 0;
200 thread->nominal_priority = thread->current_priority = priority; 203 thread->nominal_priority = thread->current_priority = priority;
201 thread->last_running_ticks = Core::Timing::GetTicks(); 204 thread->last_running_ticks = system.CoreTiming().GetTicks();
202 thread->processor_id = processor_id; 205 thread->processor_id = processor_id;
203 thread->ideal_core = processor_id; 206 thread->ideal_core = processor_id;
204 thread->affinity_mask = 1ULL << processor_id; 207 thread->affinity_mask = 1ULL << processor_id;
@@ -209,7 +212,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(KernelCore& kernel, std::string name
209 thread->name = std::move(name); 212 thread->name = std::move(name);
210 thread->callback_handle = kernel.ThreadWakeupCallbackHandleTable().Create(thread).Unwrap(); 213 thread->callback_handle = kernel.ThreadWakeupCallbackHandleTable().Create(thread).Unwrap();
211 thread->owner_process = &owner_process; 214 thread->owner_process = &owner_process;
212 thread->scheduler = &Core::System::GetInstance().Scheduler(processor_id); 215 thread->scheduler = &system.Scheduler(processor_id);
213 thread->scheduler->AddThread(thread, priority); 216 thread->scheduler->AddThread(thread, priority);
214 thread->tls_address = thread->owner_process->MarkNextAvailableTLSSlotAsUsed(*thread); 217 thread->tls_address = thread->owner_process->MarkNextAvailableTLSSlotAsUsed(*thread);
215 218
@@ -258,7 +261,7 @@ void Thread::SetStatus(ThreadStatus new_status) {
258 } 261 }
259 262
260 if (status == ThreadStatus::Running) { 263 if (status == ThreadStatus::Running) {
261 last_running_ticks = Core::Timing::GetTicks(); 264 last_running_ticks = Core::System::GetInstance().CoreTiming().GetTicks();
262 } 265 }
263 266
264 status = new_status; 267 status = new_status;