summaryrefslogtreecommitdiff
path: root/src/core/hle/svc.cpp
diff options
context:
space:
mode:
authorGravatar Kevin Hartman2015-01-25 22:56:17 -0800
committerGravatar Kevin Hartman2015-02-09 21:47:12 -0800
commit5fcbfc06eb247c0a4c1db201ac9050d80d4e4020 (patch)
tree4cdac59449b025c7a07e8655f29eda2fbcb423fe /src/core/hle/svc.cpp
parentMerge pull request #551 from bunnei/mutex-fixes (diff)
downloadyuzu-5fcbfc06eb247c0a4c1db201ac9050d80d4e4020.tar.gz
yuzu-5fcbfc06eb247c0a4c1db201ac9050d80d4e4020.tar.xz
yuzu-5fcbfc06eb247c0a4c1db201ac9050d80d4e4020.zip
Scheduler refactor Pt. 1
* Simplifies scheduling logic, specifically regarding thread status. It should be much clearer which statuses are valid for a thread at any given point in the system. * Removes dead code from thread.cpp. * Moves the implementation of resetting a ThreadContext to the corresponding core's implementation. Other changes: * Fixed comments in arm interfaces. * Updated comments in thread.cpp * Removed confusing, useless, functions like MakeReady() and ChangeStatus() from thread.cpp. * Removed stack_size from Thread. In the CTR kernel, the thread's stack would be allocated before thread creation.
Diffstat (limited to 'src/core/hle/svc.cpp')
-rw-r--r--src/core/hle/svc.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index c4866fcce..96da29923 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -150,7 +150,7 @@ static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) {
150 if (object->ShouldWait()) { 150 if (object->ShouldWait()) {
151 151
152 object->AddWaitingThread(Kernel::GetCurrentThread()); 152 object->AddWaitingThread(Kernel::GetCurrentThread());
153 Kernel::WaitCurrentThread_WaitSynchronization(object, false, false); 153 Kernel::WaitCurrentThread_WaitSynchronization({ object }, false, false);
154 154
155 // Create an event to wake the thread up after the specified nanosecond delay has passed 155 // Create an event to wake the thread up after the specified nanosecond delay has passed
156 Kernel::GetCurrentThread()->WakeAfterDelay(nano_seconds); 156 Kernel::GetCurrentThread()->WakeAfterDelay(nano_seconds);
@@ -212,7 +212,6 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou
212 // NOTE: This should deadlock the current thread if no timeout was specified 212 // NOTE: This should deadlock the current thread if no timeout was specified
213 if (!wait_all) { 213 if (!wait_all) {
214 wait_thread = true; 214 wait_thread = true;
215 Kernel::WaitCurrentThread_WaitSynchronization(nullptr, true, wait_all);
216 } 215 }
217 } 216 }
218 217
@@ -222,12 +221,17 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou
222 if (wait_thread) { 221 if (wait_thread) {
223 222
224 // Actually wait the current thread on each object if we decided to wait... 223 // Actually wait the current thread on each object if we decided to wait...
224 std::vector<SharedPtr<Kernel::WaitObject>> wait_objects;
225 wait_objects.reserve(handle_count);
226
225 for (int i = 0; i < handle_count; ++i) { 227 for (int i = 0; i < handle_count; ++i) {
226 auto object = Kernel::g_handle_table.GetWaitObject(handles[i]); 228 auto object = Kernel::g_handle_table.GetWaitObject(handles[i]);
227 object->AddWaitingThread(Kernel::GetCurrentThread()); 229 object->AddWaitingThread(Kernel::GetCurrentThread());
228 Kernel::WaitCurrentThread_WaitSynchronization(object, true, wait_all); 230 wait_objects.push_back(object);
229 } 231 }
230 232
233 Kernel::WaitCurrentThread_WaitSynchronization(std::move(wait_objects), true, wait_all);
234
231 // Create an event to wake the thread up after the specified nanosecond delay has passed 235 // Create an event to wake the thread up after the specified nanosecond delay has passed
232 Kernel::GetCurrentThread()->WakeAfterDelay(nano_seconds); 236 Kernel::GetCurrentThread()->WakeAfterDelay(nano_seconds);
233 237
@@ -319,7 +323,7 @@ static ResultCode CreateThread(u32* out_handle, u32 priority, u32 entry_point, u
319 } 323 }
320 324
321 CASCADE_RESULT(SharedPtr<Thread> thread, Kernel::Thread::Create( 325 CASCADE_RESULT(SharedPtr<Thread> thread, Kernel::Thread::Create(
322 name, entry_point, priority, arg, processor_id, stack_top, Kernel::DEFAULT_STACK_SIZE)); 326 name, entry_point, priority, arg, processor_id, stack_top));
323 CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(thread))); 327 CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(thread)));
324 328
325 LOG_TRACE(Kernel_SVC, "called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, " 329 LOG_TRACE(Kernel_SVC, "called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, "
@@ -338,7 +342,7 @@ static ResultCode CreateThread(u32* out_handle, u32 priority, u32 entry_point, u
338static void ExitThread() { 342static void ExitThread() {
339 LOG_TRACE(Kernel_SVC, "called, pc=0x%08X", Core::g_app_core->GetPC()); 343 LOG_TRACE(Kernel_SVC, "called, pc=0x%08X", Core::g_app_core->GetPC());
340 344
341 Kernel::GetCurrentThread()->Stop(__func__); 345 Kernel::GetCurrentThread()->Stop();
342 HLE::Reschedule(__func__); 346 HLE::Reschedule(__func__);
343} 347}
344 348