summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/kernel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
-rw-r--r--src/core/hle/kernel/kernel.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 1db8e102f..ef9dbafa5 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -39,11 +39,6 @@ SharedPtr<Thread> WaitObject::GetHighestPriorityReadyThread() {
39 thread->status == THREADSTATUS_DEAD; 39 thread->status == THREADSTATUS_DEAD;
40 }); 40 });
41 41
42 // TODO(Subv): This call should be performed inside the loop below to check if an object can be
43 // acquired by a particular thread. This is useful for things like recursive locking of Mutexes.
44 if (ShouldWait())
45 return nullptr;
46
47 Thread* candidate = nullptr; 42 Thread* candidate = nullptr;
48 s32 candidate_priority = THREADPRIO_LOWEST + 1; 43 s32 candidate_priority = THREADPRIO_LOWEST + 1;
49 44
@@ -51,9 +46,12 @@ SharedPtr<Thread> WaitObject::GetHighestPriorityReadyThread() {
51 if (thread->current_priority >= candidate_priority) 46 if (thread->current_priority >= candidate_priority)
52 continue; 47 continue;
53 48
49 if (ShouldWait(thread.get()))
50 continue;
51
54 bool ready_to_run = 52 bool ready_to_run =
55 std::none_of(thread->wait_objects.begin(), thread->wait_objects.end(), 53 std::none_of(thread->wait_objects.begin(), thread->wait_objects.end(),
56 [](const SharedPtr<WaitObject>& object) { return object->ShouldWait(); }); 54 [&thread](const SharedPtr<WaitObject>& object) { return object->ShouldWait(thread.get()); });
57 if (ready_to_run) { 55 if (ready_to_run) {
58 candidate = thread.get(); 56 candidate = thread.get();
59 candidate_priority = thread->current_priority; 57 candidate_priority = thread->current_priority;
@@ -66,7 +64,7 @@ SharedPtr<Thread> WaitObject::GetHighestPriorityReadyThread() {
66void WaitObject::WakeupAllWaitingThreads() { 64void WaitObject::WakeupAllWaitingThreads() {
67 while (auto thread = GetHighestPriorityReadyThread()) { 65 while (auto thread = GetHighestPriorityReadyThread()) {
68 if (!thread->IsSleepingOnWaitAll()) { 66 if (!thread->IsSleepingOnWaitAll()) {
69 Acquire(); 67 Acquire(thread.get());
70 // Set the output index of the WaitSynchronizationN call to the index of this object. 68 // Set the output index of the WaitSynchronizationN call to the index of this object.
71 if (thread->wait_set_output) { 69 if (thread->wait_set_output) {
72 thread->SetWaitSynchronizationOutput(thread->GetWaitObjectIndex(this)); 70 thread->SetWaitSynchronizationOutput(thread->GetWaitObjectIndex(this));
@@ -74,7 +72,7 @@ void WaitObject::WakeupAllWaitingThreads() {
74 } 72 }
75 } else { 73 } else {
76 for (auto& object : thread->wait_objects) { 74 for (auto& object : thread->wait_objects) {
77 object->Acquire(); 75 object->Acquire(thread.get());
78 object->RemoveWaitingThread(thread.get()); 76 object->RemoveWaitingThread(thread.get());
79 } 77 }
80 // Note: This case doesn't update the output index of WaitSynchronizationN. 78 // Note: This case doesn't update the output index of WaitSynchronizationN.