summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2015-01-30 23:07:54 -0200
committerGravatar Yuri Kunde Schlesner2015-02-02 15:37:01 -0200
commit664c79ff47054df845096e7e29d5cc437dfec2a2 (patch)
tree1ebd682a7e75c964f2ac98f2dffbc5adba037442 /src/core/hle/kernel
parentService: Store function names as const char* instead of std::string (diff)
downloadyuzu-664c79ff47054df845096e7e29d5cc437dfec2a2.tar.gz
yuzu-664c79ff47054df845096e7e29d5cc437dfec2a2.tar.xz
yuzu-664c79ff47054df845096e7e29d5cc437dfec2a2.zip
Thread: Modernize two functions that slipped through previous rebases
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/address_arbiter.cpp4
-rw-r--r--src/core/hle/kernel/thread.cpp9
-rw-r--r--src/core/hle/kernel/thread.h15
3 files changed, 13 insertions, 15 deletions
diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp
index 2d01e2ef5..6e8f959f3 100644
--- a/src/core/hle/kernel/address_arbiter.cpp
+++ b/src/core/hle/kernel/address_arbiter.cpp
@@ -51,7 +51,7 @@ ResultCode AddressArbiter::ArbitrateAddress(ArbitrationType type, VAddr address,
51 case ArbitrationType::WaitIfLessThanWithTimeout: 51 case ArbitrationType::WaitIfLessThanWithTimeout:
52 if ((s32)Memory::Read32(address) <= value) { 52 if ((s32)Memory::Read32(address) <= value) {
53 Kernel::WaitCurrentThread_ArbitrateAddress(address); 53 Kernel::WaitCurrentThread_ArbitrateAddress(address);
54 Kernel::WakeThreadAfterDelay(GetCurrentThread(), nanoseconds); 54 GetCurrentThread()->WakeAfterDelay(nanoseconds);
55 HLE::Reschedule(__func__); 55 HLE::Reschedule(__func__);
56 } 56 }
57 break; 57 break;
@@ -71,7 +71,7 @@ ResultCode AddressArbiter::ArbitrateAddress(ArbitrationType type, VAddr address,
71 Memory::Write32(address, memory_value); 71 Memory::Write32(address, memory_value);
72 if (memory_value <= value) { 72 if (memory_value <= value) {
73 Kernel::WaitCurrentThread_ArbitrateAddress(address); 73 Kernel::WaitCurrentThread_ArbitrateAddress(address);
74 Kernel::WakeThreadAfterDelay(GetCurrentThread(), nanoseconds); 74 GetCurrentThread()->WakeAfterDelay(nanoseconds);
75 HLE::Reschedule(__func__); 75 HLE::Reschedule(__func__);
76 } 76 }
77 break; 77 break;
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 56950ebd4..1ea5589cb 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -248,14 +248,13 @@ static void ThreadWakeupCallback(u64 parameter, int cycles_late) {
248} 248}
249 249
250 250
251void WakeThreadAfterDelay(Thread* thread, s64 nanoseconds) { 251void Thread::WakeAfterDelay(s64 nanoseconds) {
252 // Don't schedule a wakeup if the thread wants to wait forever 252 // Don't schedule a wakeup if the thread wants to wait forever
253 if (nanoseconds == -1) 253 if (nanoseconds == -1)
254 return; 254 return;
255 _dbg_assert_(Kernel, thread != nullptr);
256 255
257 u64 microseconds = nanoseconds / 1000; 256 u64 microseconds = nanoseconds / 1000;
258 CoreTiming::ScheduleEvent(usToCycles(microseconds), ThreadWakeupEventType, thread->GetHandle()); 257 CoreTiming::ScheduleEvent(usToCycles(microseconds), ThreadWakeupEventType, GetHandle());
259} 258}
260 259
261void Thread::ReleaseWaitObject(WaitObject* wait_object) { 260void Thread::ReleaseWaitObject(WaitObject* wait_object) {
@@ -418,7 +417,7 @@ void Thread::SetPriority(s32 priority) {
418 } 417 }
419} 418}
420 419
421Handle SetupIdleThread() { 420SharedPtr<Thread> SetupIdleThread() {
422 // We need to pass a few valid values to get around parameter checking in Thread::Create. 421 // We need to pass a few valid values to get around parameter checking in Thread::Create.
423 auto thread_res = Thread::Create("idle", Memory::KERNEL_MEMORY_VADDR, THREADPRIO_LOWEST, 0, 422 auto thread_res = Thread::Create("idle", Memory::KERNEL_MEMORY_VADDR, THREADPRIO_LOWEST, 0,
424 THREADPROCESSORID_0, 0, Kernel::DEFAULT_STACK_SIZE); 423 THREADPROCESSORID_0, 0, Kernel::DEFAULT_STACK_SIZE);
@@ -427,7 +426,7 @@ Handle SetupIdleThread() {
427 426
428 thread->idle = true; 427 thread->idle = true;
429 CallThread(thread.get()); 428 CallThread(thread.get());
430 return thread->GetHandle(); 429 return thread;
431} 430}
432 431
433SharedPtr<Thread> SetupMainThread(s32 priority, u32 stack_size) { 432SharedPtr<Thread> SetupMainThread(s32 priority, u32 stack_size) {
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index d6299364a..cba074e07 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -78,6 +78,12 @@ public:
78 void ResumeFromWait(); 78 void ResumeFromWait();
79 79
80 /** 80 /**
81 * Schedules an event to wake up the specified thread after the specified delay.
82 * @param nanoseconds The time this thread will be allowed to sleep for.
83 */
84 void WakeAfterDelay(s64 nanoseconds);
85
86 /**
81 * Sets the result after the thread awakens (from either WaitSynchronization SVC) 87 * Sets the result after the thread awakens (from either WaitSynchronization SVC)
82 * @param result Value to set to the returned result 88 * @param result Value to set to the returned result
83 */ 89 */
@@ -151,19 +157,12 @@ void WaitCurrentThread_WaitSynchronization(SharedPtr<WaitObject> wait_object, bo
151void WaitCurrentThread_ArbitrateAddress(VAddr wait_address); 157void WaitCurrentThread_ArbitrateAddress(VAddr wait_address);
152 158
153/** 159/**
154 * Schedules an event to wake up the specified thread after the specified delay.
155 * @param handle The thread handle.
156 * @param nanoseconds The time this thread will be allowed to sleep for.
157 */
158void WakeThreadAfterDelay(Thread* thread, s64 nanoseconds);
159
160/**
161 * Sets up the idle thread, this is a thread that is intended to never execute instructions, 160 * Sets up the idle thread, this is a thread that is intended to never execute instructions,
162 * only to advance the timing. It is scheduled when there are no other ready threads in the thread queue 161 * only to advance the timing. It is scheduled when there are no other ready threads in the thread queue
163 * and will try to yield on every call. 162 * and will try to yield on every call.
164 * @returns The handle of the idle thread 163 * @returns The handle of the idle thread
165 */ 164 */
166Handle SetupIdleThread(); 165SharedPtr<Thread> SetupIdleThread();
167 166
168/// Initialize threading 167/// Initialize threading
169void ThreadingInit(); 168void ThreadingInit();