From e0e744351795e96e1e0cc0f16d0f75476e06ede5 Mon Sep 17 00:00:00 2001 From: bunnei Date: Wed, 26 Nov 2014 00:34:14 -0500 Subject: [PATCH 1/3] SVC: SleepThread should yield to the next ready thread. --- src/core/hle/svc.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 87d768856..48c8dee1e 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -331,6 +331,9 @@ static Result ClearEvent(Handle evt) { /// Sleep the current thread static void SleepThread(s64 nanoseconds) { DEBUG_LOG(SVC, "called nanoseconds=%lld", nanoseconds); + + // Check for next thread to schedule + HLE::Reschedule(__func__); } /// This returns the total CPU ticks elapsed since the CPU was powered-on From f985469901f4056a8bb597d1a0bdecb40d7139eb Mon Sep 17 00:00:00 2001 From: bunnei Date: Wed, 26 Nov 2014 00:35:20 -0500 Subject: [PATCH 2/3] SVC: Add debug log to ArbitrateAddress. --- src/core/hle/svc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 48c8dee1e..43a3cbe03 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -189,6 +189,8 @@ static Result CreateAddressArbiter(u32* arbiter) { /// Arbitrate address static Result ArbitrateAddress(Handle arbiter, u32 address, u32 type, u32 value, s64 nanoseconds) { + DEBUG_LOG(SVC, "called handle=0x%08X, address=0x%08X, type=0x%08X, value=0x%08X", arbiter, + address, type, value); return Kernel::ArbitrateAddress(arbiter, static_cast(type), address, value).raw; } From de851ba1a18ce2439a0b8ad46081990df377347c Mon Sep 17 00:00:00 2001 From: bunnei Date: Wed, 26 Nov 2014 00:38:50 -0500 Subject: [PATCH 3/3] Thread: Check that thread is actually in "wait state" when verifying wait. --- src/core/hle/kernel/thread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index f3f54a4e9..f59795901 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -143,7 +143,7 @@ void ChangeReadyState(Thread* t, bool ready) { /// Verify that a thread has not been released from waiting inline bool VerifyWait(const Thread* thread, WaitType type, Handle wait_handle) { _dbg_assert_(KERNEL, thread != nullptr); - return type == thread->wait_type && wait_handle == thread->wait_handle; + return (type == thread->wait_type) && (wait_handle == thread->wait_handle) && (thread->IsWaiting()); } /// Stops the current thread