summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/k_light_lock.cpp19
-rw-r--r--src/core/hle/kernel/k_process.cpp16
2 files changed, 12 insertions, 23 deletions
diff --git a/src/core/hle/kernel/k_light_lock.cpp b/src/core/hle/kernel/k_light_lock.cpp
index f974022e8..0896e705f 100644
--- a/src/core/hle/kernel/k_light_lock.cpp
+++ b/src/core/hle/kernel/k_light_lock.cpp
@@ -59,11 +59,7 @@ void KLightLock::LockSlowPath(uintptr_t _owner, uintptr_t _cur_thread) {
59 owner_thread->AddWaiter(cur_thread); 59 owner_thread->AddWaiter(cur_thread);
60 60
61 // Set thread states. 61 // Set thread states.
62 if (cur_thread->GetState() == ThreadState::Runnable) { 62 cur_thread->SetState(ThreadState::Waiting);
63 cur_thread->SetState(ThreadState::Waiting);
64 } else {
65 KScheduler::SetSchedulerUpdateNeeded(kernel);
66 }
67 63
68 if (owner_thread->IsSuspended()) { 64 if (owner_thread->IsSuspended()) {
69 owner_thread->ContinueIfHasKernelWaiters(); 65 owner_thread->ContinueIfHasKernelWaiters();
@@ -73,10 +69,9 @@ void KLightLock::LockSlowPath(uintptr_t _owner, uintptr_t _cur_thread) {
73 // We're no longer waiting on the lock owner. 69 // We're no longer waiting on the lock owner.
74 { 70 {
75 KScopedSchedulerLock sl{kernel}; 71 KScopedSchedulerLock sl{kernel};
76 KThread* owner_thread = cur_thread->GetLockOwner(); 72
77 if (owner_thread) { 73 if (KThread* owner_thread = cur_thread->GetLockOwner(); owner_thread != nullptr) {
78 owner_thread->RemoveWaiter(cur_thread); 74 owner_thread->RemoveWaiter(cur_thread);
79 KScheduler::SetSchedulerUpdateNeeded(kernel);
80 } 75 }
81 } 76 }
82} 77}
@@ -95,17 +90,13 @@ void KLightLock::UnlockSlowPath(uintptr_t _cur_thread) {
95 90
96 // Pass the lock to the next owner. 91 // Pass the lock to the next owner.
97 uintptr_t next_tag = 0; 92 uintptr_t next_tag = 0;
98 if (next_owner) { 93 if (next_owner != nullptr) {
99 next_tag = reinterpret_cast<uintptr_t>(next_owner); 94 next_tag = reinterpret_cast<uintptr_t>(next_owner);
100 if (num_waiters > 1) { 95 if (num_waiters > 1) {
101 next_tag |= 0x1; 96 next_tag |= 0x1;
102 } 97 }
103 98
104 if (next_owner->GetState() == ThreadState::Waiting) { 99 next_owner->SetState(ThreadState::Runnable);
105 next_owner->SetState(ThreadState::Runnable);
106 } else {
107 KScheduler::SetSchedulerUpdateNeeded(kernel);
108 }
109 100
110 if (next_owner->IsSuspended()) { 101 if (next_owner->IsSuspended()) {
111 next_owner->ContinueIfHasKernelWaiters(); 102 next_owner->ContinueIfHasKernelWaiters();
diff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cpp
index 06b8ce151..d1bd98051 100644
--- a/src/core/hle/kernel/k_process.cpp
+++ b/src/core/hle/kernel/k_process.cpp
@@ -201,17 +201,15 @@ bool KProcess::ReleaseUserException(KThread* thread) {
201 201
202 // Remove waiter thread. 202 // Remove waiter thread.
203 s32 num_waiters{}; 203 s32 num_waiters{};
204 KThread* next = thread->RemoveWaiterByKey( 204 if (KThread* next = thread->RemoveWaiterByKey(
205 std::addressof(num_waiters), 205 std::addressof(num_waiters),
206 reinterpret_cast<uintptr_t>(std::addressof(exception_thread))); 206 reinterpret_cast<uintptr_t>(std::addressof(exception_thread)));
207 if (next != nullptr) { 207 next != nullptr) {
208 if (next->GetState() == ThreadState::Waiting) { 208 next->SetState(ThreadState::Runnable);
209 next->SetState(ThreadState::Runnable);
210 } else {
211 KScheduler::SetSchedulerUpdateNeeded(kernel);
212 }
213 } 209 }
214 210
211 KScheduler::SetSchedulerUpdateNeeded(kernel);
212
215 return true; 213 return true;
216 } else { 214 } else {
217 return false; 215 return false;