summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/client_session.cpp2
-rw-r--r--src/core/hle/kernel/client_session.h4
-rw-r--r--src/core/hle/kernel/hle_ipc.cpp20
-rw-r--r--src/core/hle/kernel/kernel.cpp4
-rw-r--r--src/core/hle/kernel/process.cpp2
-rw-r--r--src/core/hle/kernel/process.h4
-rw-r--r--src/core/hle/kernel/readable_event.cpp2
-rw-r--r--src/core/hle/kernel/readable_event.h4
-rw-r--r--src/core/hle/kernel/server_port.cpp2
-rw-r--r--src/core/hle/kernel/server_port.h4
-rw-r--r--src/core/hle/kernel/server_session.cpp2
-rw-r--r--src/core/hle/kernel/server_session.h4
-rw-r--r--src/core/hle/kernel/session.cpp2
-rw-r--r--src/core/hle/kernel/session.h4
-rw-r--r--src/core/hle/kernel/svc.cpp13
-rw-r--r--src/core/hle/kernel/synchronization_object.cpp (renamed from src/core/hle/kernel/wait_object.cpp)23
-rw-r--r--src/core/hle/kernel/synchronization_object.h (renamed from src/core/hle/kernel/wait_object.h)13
-rw-r--r--src/core/hle/kernel/thread.cpp16
-rw-r--r--src/core/hle/kernel/thread.h22
19 files changed, 76 insertions, 71 deletions
diff --git a/src/core/hle/kernel/client_session.cpp b/src/core/hle/kernel/client_session.cpp
index 4669a14ad..3dfeb9813 100644
--- a/src/core/hle/kernel/client_session.cpp
+++ b/src/core/hle/kernel/client_session.cpp
@@ -12,7 +12,7 @@
12 12
13namespace Kernel { 13namespace Kernel {
14 14
15ClientSession::ClientSession(KernelCore& kernel) : WaitObject{kernel} {} 15ClientSession::ClientSession(KernelCore& kernel) : SynchronizationObject{kernel} {}
16 16
17ClientSession::~ClientSession() { 17ClientSession::~ClientSession() {
18 // This destructor will be called automatically when the last ClientSession handle is closed by 18 // This destructor will be called automatically when the last ClientSession handle is closed by
diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h
index b4289a9a8..9cf9219b1 100644
--- a/src/core/hle/kernel/client_session.h
+++ b/src/core/hle/kernel/client_session.h
@@ -7,7 +7,7 @@
7#include <memory> 7#include <memory>
8#include <string> 8#include <string>
9 9
10#include "core/hle/kernel/wait_object.h" 10#include "core/hle/kernel/synchronization_object.h"
11#include "core/hle/result.h" 11#include "core/hle/result.h"
12 12
13union ResultCode; 13union ResultCode;
@@ -22,7 +22,7 @@ class KernelCore;
22class Session; 22class Session;
23class Thread; 23class Thread;
24 24
25class ClientSession final : public WaitObject { 25class ClientSession final : public SynchronizationObject {
26public: 26public:
27 explicit ClientSession(KernelCore& kernel); 27 explicit ClientSession(KernelCore& kernel);
28 ~ClientSession() override; 28 ~ClientSession() override;
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp
index ab05788d7..c558a2f33 100644
--- a/src/core/hle/kernel/hle_ipc.cpp
+++ b/src/core/hle/kernel/hle_ipc.cpp
@@ -47,15 +47,15 @@ std::shared_ptr<WritableEvent> HLERequestContext::SleepClientThread(
47 const std::string& reason, u64 timeout, WakeupCallback&& callback, 47 const std::string& reason, u64 timeout, WakeupCallback&& callback,
48 std::shared_ptr<WritableEvent> writable_event) { 48 std::shared_ptr<WritableEvent> writable_event) {
49 // Put the client thread to sleep until the wait event is signaled or the timeout expires. 49 // Put the client thread to sleep until the wait event is signaled or the timeout expires.
50 thread->SetWakeupCallback([context = *this, callback](ThreadWakeupReason reason, 50 thread->SetWakeupCallback(
51 std::shared_ptr<Thread> thread, 51 [context = *this, callback](ThreadWakeupReason reason, std::shared_ptr<Thread> thread,
52 std::shared_ptr<WaitObject> object, 52 std::shared_ptr<SynchronizationObject> object,
53 std::size_t index) mutable -> bool { 53 std::size_t index) mutable -> bool {
54 ASSERT(thread->GetStatus() == ThreadStatus::WaitHLEEvent); 54 ASSERT(thread->GetStatus() == ThreadStatus::WaitHLEEvent);
55 callback(thread, context, reason); 55 callback(thread, context, reason);
56 context.WriteToOutgoingCommandBuffer(*thread); 56 context.WriteToOutgoingCommandBuffer(*thread);
57 return true; 57 return true;
58 }); 58 });
59 59
60 auto& kernel = Core::System::GetInstance().Kernel(); 60 auto& kernel = Core::System::GetInstance().Kernel();
61 if (!writable_event) { 61 if (!writable_event) {
@@ -67,7 +67,7 @@ std::shared_ptr<WritableEvent> HLERequestContext::SleepClientThread(
67 const auto readable_event{writable_event->GetReadableEvent()}; 67 const auto readable_event{writable_event->GetReadableEvent()};
68 writable_event->Clear(); 68 writable_event->Clear();
69 thread->SetStatus(ThreadStatus::WaitHLEEvent); 69 thread->SetStatus(ThreadStatus::WaitHLEEvent);
70 thread->SetWaitObjects({readable_event}); 70 thread->SetSynchronizationObjects({readable_event});
71 readable_event->AddWaitingThread(thread); 71 readable_event->AddWaitingThread(thread);
72 72
73 if (timeout > 0) { 73 if (timeout > 0) {
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index edd4c4259..26799f6b5 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -54,10 +54,10 @@ static void ThreadWakeupCallback(u64 thread_handle, [[maybe_unused]] s64 cycles_
54 if (thread->GetStatus() == ThreadStatus::WaitSynch || 54 if (thread->GetStatus() == ThreadStatus::WaitSynch ||
55 thread->GetStatus() == ThreadStatus::WaitHLEEvent) { 55 thread->GetStatus() == ThreadStatus::WaitHLEEvent) {
56 // Remove the thread from each of its waiting objects' waitlists 56 // Remove the thread from each of its waiting objects' waitlists
57 for (const auto& object : thread->GetWaitObjects()) { 57 for (const auto& object : thread->GetSynchronizationObjects()) {
58 object->RemoveWaitingThread(thread); 58 object->RemoveWaitingThread(thread);
59 } 59 }
60 thread->ClearWaitObjects(); 60 thread->ClearSynchronizationObjects();
61 61
62 // Invoke the wakeup callback before clearing the wait objects 62 // Invoke the wakeup callback before clearing the wait objects
63 if (thread->HasWakeupCallback()) { 63 if (thread->HasWakeupCallback()) {
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp
index b9035a0be..7a616435a 100644
--- a/src/core/hle/kernel/process.cpp
+++ b/src/core/hle/kernel/process.cpp
@@ -337,7 +337,7 @@ void Process::LoadModule(CodeSet module_, VAddr base_addr) {
337} 337}
338 338
339Process::Process(Core::System& system) 339Process::Process(Core::System& system)
340 : WaitObject{system.Kernel()}, vm_manager{system}, 340 : SynchronizationObject{system.Kernel()}, vm_manager{system},
341 address_arbiter{system}, mutex{system}, system{system} {} 341 address_arbiter{system}, mutex{system}, system{system} {}
342 342
343Process::~Process() = default; 343Process::~Process() = default;
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h
index 3483fa19d..7b64c564a 100644
--- a/src/core/hle/kernel/process.h
+++ b/src/core/hle/kernel/process.h
@@ -15,8 +15,8 @@
15#include "core/hle/kernel/handle_table.h" 15#include "core/hle/kernel/handle_table.h"
16#include "core/hle/kernel/mutex.h" 16#include "core/hle/kernel/mutex.h"
17#include "core/hle/kernel/process_capability.h" 17#include "core/hle/kernel/process_capability.h"
18#include "core/hle/kernel/synchronization_object.h"
18#include "core/hle/kernel/vm_manager.h" 19#include "core/hle/kernel/vm_manager.h"
19#include "core/hle/kernel/wait_object.h"
20#include "core/hle/result.h" 20#include "core/hle/result.h"
21 21
22namespace Core { 22namespace Core {
@@ -60,7 +60,7 @@ enum class ProcessStatus {
60 DebugBreak, 60 DebugBreak,
61}; 61};
62 62
63class Process final : public WaitObject { 63class Process final : public SynchronizationObject {
64public: 64public:
65 explicit Process(Core::System& system); 65 explicit Process(Core::System& system);
66 ~Process() override; 66 ~Process() override;
diff --git a/src/core/hle/kernel/readable_event.cpp b/src/core/hle/kernel/readable_event.cpp
index d8ac97aa1..8ab796ba8 100644
--- a/src/core/hle/kernel/readable_event.cpp
+++ b/src/core/hle/kernel/readable_event.cpp
@@ -11,7 +11,7 @@
11 11
12namespace Kernel { 12namespace Kernel {
13 13
14ReadableEvent::ReadableEvent(KernelCore& kernel) : WaitObject{kernel} {} 14ReadableEvent::ReadableEvent(KernelCore& kernel) : SynchronizationObject{kernel} {}
15ReadableEvent::~ReadableEvent() = default; 15ReadableEvent::~ReadableEvent() = default;
16 16
17bool ReadableEvent::ShouldWait(const Thread* thread) const { 17bool ReadableEvent::ShouldWait(const Thread* thread) const {
diff --git a/src/core/hle/kernel/readable_event.h b/src/core/hle/kernel/readable_event.h
index 11ff71c3a..c7b0d6add 100644
--- a/src/core/hle/kernel/readable_event.h
+++ b/src/core/hle/kernel/readable_event.h
@@ -5,7 +5,7 @@
5#pragma once 5#pragma once
6 6
7#include "core/hle/kernel/object.h" 7#include "core/hle/kernel/object.h"
8#include "core/hle/kernel/wait_object.h" 8#include "core/hle/kernel/synchronization_object.h"
9 9
10union ResultCode; 10union ResultCode;
11 11
@@ -14,7 +14,7 @@ namespace Kernel {
14class KernelCore; 14class KernelCore;
15class WritableEvent; 15class WritableEvent;
16 16
17class ReadableEvent final : public WaitObject { 17class ReadableEvent final : public SynchronizationObject {
18 friend class WritableEvent; 18 friend class WritableEvent;
19 19
20public: 20public:
diff --git a/src/core/hle/kernel/server_port.cpp b/src/core/hle/kernel/server_port.cpp
index a4ccfa35e..4f02f8df2 100644
--- a/src/core/hle/kernel/server_port.cpp
+++ b/src/core/hle/kernel/server_port.cpp
@@ -13,7 +13,7 @@
13 13
14namespace Kernel { 14namespace Kernel {
15 15
16ServerPort::ServerPort(KernelCore& kernel) : WaitObject{kernel} {} 16ServerPort::ServerPort(KernelCore& kernel) : SynchronizationObject{kernel} {}
17ServerPort::~ServerPort() = default; 17ServerPort::~ServerPort() = default;
18 18
19ResultVal<std::shared_ptr<ServerSession>> ServerPort::Accept() { 19ResultVal<std::shared_ptr<ServerSession>> ServerPort::Accept() {
diff --git a/src/core/hle/kernel/server_port.h b/src/core/hle/kernel/server_port.h
index 8be8a75ea..43cf3ae18 100644
--- a/src/core/hle/kernel/server_port.h
+++ b/src/core/hle/kernel/server_port.h
@@ -10,7 +10,7 @@
10#include <vector> 10#include <vector>
11#include "common/common_types.h" 11#include "common/common_types.h"
12#include "core/hle/kernel/object.h" 12#include "core/hle/kernel/object.h"
13#include "core/hle/kernel/wait_object.h" 13#include "core/hle/kernel/synchronization_object.h"
14#include "core/hle/result.h" 14#include "core/hle/result.h"
15 15
16namespace Kernel { 16namespace Kernel {
@@ -20,7 +20,7 @@ class KernelCore;
20class ServerSession; 20class ServerSession;
21class SessionRequestHandler; 21class SessionRequestHandler;
22 22
23class ServerPort final : public WaitObject { 23class ServerPort final : public SynchronizationObject {
24public: 24public:
25 explicit ServerPort(KernelCore& kernel); 25 explicit ServerPort(KernelCore& kernel);
26 ~ServerPort() override; 26 ~ServerPort() override;
diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp
index 7825e1ec4..8207f71c3 100644
--- a/src/core/hle/kernel/server_session.cpp
+++ b/src/core/hle/kernel/server_session.cpp
@@ -24,7 +24,7 @@
24 24
25namespace Kernel { 25namespace Kernel {
26 26
27ServerSession::ServerSession(KernelCore& kernel) : WaitObject{kernel} {} 27ServerSession::ServerSession(KernelCore& kernel) : SynchronizationObject{kernel} {}
28ServerSession::~ServerSession() = default; 28ServerSession::~ServerSession() = default;
29 29
30ResultVal<std::shared_ptr<ServerSession>> ServerSession::Create(KernelCore& kernel, 30ResultVal<std::shared_ptr<ServerSession>> ServerSession::Create(KernelCore& kernel,
diff --git a/src/core/hle/kernel/server_session.h b/src/core/hle/kernel/server_session.h
index d6e48109e..3688c7d11 100644
--- a/src/core/hle/kernel/server_session.h
+++ b/src/core/hle/kernel/server_session.h
@@ -10,7 +10,7 @@
10#include <vector> 10#include <vector>
11 11
12#include "common/threadsafe_queue.h" 12#include "common/threadsafe_queue.h"
13#include "core/hle/kernel/wait_object.h" 13#include "core/hle/kernel/synchronization_object.h"
14#include "core/hle/result.h" 14#include "core/hle/result.h"
15 15
16namespace Memory { 16namespace Memory {
@@ -41,7 +41,7 @@ class Thread;
41 * After the server replies to the request, the response is marshalled back to the caller's 41 * After the server replies to the request, the response is marshalled back to the caller's
42 * TLS buffer and control is transferred back to it. 42 * TLS buffer and control is transferred back to it.
43 */ 43 */
44class ServerSession final : public WaitObject { 44class ServerSession final : public SynchronizationObject {
45public: 45public:
46 explicit ServerSession(KernelCore& kernel); 46 explicit ServerSession(KernelCore& kernel);
47 ~ServerSession() override; 47 ~ServerSession() override;
diff --git a/src/core/hle/kernel/session.cpp b/src/core/hle/kernel/session.cpp
index dee6e2b72..1c1fc440d 100644
--- a/src/core/hle/kernel/session.cpp
+++ b/src/core/hle/kernel/session.cpp
@@ -9,7 +9,7 @@
9 9
10namespace Kernel { 10namespace Kernel {
11 11
12Session::Session(KernelCore& kernel) : WaitObject{kernel} {} 12Session::Session(KernelCore& kernel) : SynchronizationObject{kernel} {}
13Session::~Session() = default; 13Session::~Session() = default;
14 14
15Session::SessionPair Session::Create(KernelCore& kernel, std::string name) { 15Session::SessionPair Session::Create(KernelCore& kernel, std::string name) {
diff --git a/src/core/hle/kernel/session.h b/src/core/hle/kernel/session.h
index 15a5ac15f..d107dd9aa 100644
--- a/src/core/hle/kernel/session.h
+++ b/src/core/hle/kernel/session.h
@@ -8,7 +8,7 @@
8#include <string> 8#include <string>
9#include <utility> 9#include <utility>
10 10
11#include "core/hle/kernel/wait_object.h" 11#include "core/hle/kernel/synchronization_object.h"
12 12
13namespace Kernel { 13namespace Kernel {
14 14
@@ -19,7 +19,7 @@ class ServerSession;
19 * Parent structure to link the client and server endpoints of a session with their associated 19 * Parent structure to link the client and server endpoints of a session with their associated
20 * client port. 20 * client port.
21 */ 21 */
22class Session final : public WaitObject { 22class Session final : public SynchronizationObject {
23public: 23public:
24 explicit Session(KernelCore& kernel); 24 explicit Session(KernelCore& kernel);
25 ~Session() override; 25 ~Session() override;
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 9cae5c73d..39552a176 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -435,7 +435,8 @@ static ResultCode GetProcessId(Core::System& system, u64* process_id, Handle han
435 435
436/// Default thread wakeup callback for WaitSynchronization 436/// Default thread wakeup callback for WaitSynchronization
437static bool DefaultThreadWakeupCallback(ThreadWakeupReason reason, std::shared_ptr<Thread> thread, 437static bool DefaultThreadWakeupCallback(ThreadWakeupReason reason, std::shared_ptr<Thread> thread,
438 std::shared_ptr<WaitObject> object, std::size_t index) { 438 std::shared_ptr<SynchronizationObject> object,
439 std::size_t index) {
439 ASSERT(thread->GetStatus() == ThreadStatus::WaitSynch); 440 ASSERT(thread->GetStatus() == ThreadStatus::WaitSynch);
440 441
441 if (reason == ThreadWakeupReason::Timeout) { 442 if (reason == ThreadWakeupReason::Timeout) {
@@ -473,13 +474,13 @@ static ResultCode WaitSynchronization(Core::System& system, Handle* index, VAddr
473 474
474 auto* const thread = system.CurrentScheduler().GetCurrentThread(); 475 auto* const thread = system.CurrentScheduler().GetCurrentThread();
475 476
476 using ObjectPtr = Thread::ThreadWaitObjects::value_type; 477 using ObjectPtr = Thread::ThreadSynchronizationObjects::value_type;
477 Thread::ThreadWaitObjects objects(handle_count); 478 Thread::ThreadSynchronizationObjects objects(handle_count);
478 const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); 479 const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
479 480
480 for (u64 i = 0; i < handle_count; ++i) { 481 for (u64 i = 0; i < handle_count; ++i) {
481 const Handle handle = memory.Read32(handles_address + i * sizeof(Handle)); 482 const Handle handle = memory.Read32(handles_address + i * sizeof(Handle));
482 const auto object = handle_table.Get<WaitObject>(handle); 483 const auto object = handle_table.Get<SynchronizationObject>(handle);
483 484
484 if (object == nullptr) { 485 if (object == nullptr) {
485 LOG_ERROR(Kernel_SVC, "Object is a nullptr"); 486 LOG_ERROR(Kernel_SVC, "Object is a nullptr");
@@ -496,7 +497,7 @@ static ResultCode WaitSynchronization(Core::System& system, Handle* index, VAddr
496 497
497 if (itr != objects.end()) { 498 if (itr != objects.end()) {
498 // We found a ready object, acquire it and set the result value 499 // We found a ready object, acquire it and set the result value
499 WaitObject* object = itr->get(); 500 SynchronizationObject* object = itr->get();
500 object->Acquire(thread); 501 object->Acquire(thread);
501 *index = static_cast<s32>(std::distance(objects.begin(), itr)); 502 *index = static_cast<s32>(std::distance(objects.begin(), itr));
502 return RESULT_SUCCESS; 503 return RESULT_SUCCESS;
@@ -519,7 +520,7 @@ static ResultCode WaitSynchronization(Core::System& system, Handle* index, VAddr
519 object->AddWaitingThread(SharedFrom(thread)); 520 object->AddWaitingThread(SharedFrom(thread));
520 } 521 }
521 522
522 thread->SetWaitObjects(std::move(objects)); 523 thread->SetSynchronizationObjects(std::move(objects));
523 thread->SetStatus(ThreadStatus::WaitSynch); 524 thread->SetStatus(ThreadStatus::WaitSynch);
524 525
525 // Create an event to wake the thread up after the specified nanosecond delay has passed 526 // Create an event to wake the thread up after the specified nanosecond delay has passed
diff --git a/src/core/hle/kernel/wait_object.cpp b/src/core/hle/kernel/synchronization_object.cpp
index 1838260fd..95f3f9245 100644
--- a/src/core/hle/kernel/wait_object.cpp
+++ b/src/core/hle/kernel/synchronization_object.cpp
@@ -10,20 +10,21 @@
10#include "core/hle/kernel/kernel.h" 10#include "core/hle/kernel/kernel.h"
11#include "core/hle/kernel/object.h" 11#include "core/hle/kernel/object.h"
12#include "core/hle/kernel/process.h" 12#include "core/hle/kernel/process.h"
13#include "core/hle/kernel/synchronization_object.h"
13#include "core/hle/kernel/thread.h" 14#include "core/hle/kernel/thread.h"
14 15
15namespace Kernel { 16namespace Kernel {
16 17
17WaitObject::WaitObject(KernelCore& kernel) : Object{kernel} {} 18SynchronizationObject::SynchronizationObject(KernelCore& kernel) : Object{kernel} {}
18WaitObject::~WaitObject() = default; 19SynchronizationObject::~SynchronizationObject() = default;
19 20
20void WaitObject::AddWaitingThread(std::shared_ptr<Thread> thread) { 21void SynchronizationObject::AddWaitingThread(std::shared_ptr<Thread> thread) {
21 auto itr = std::find(waiting_threads.begin(), waiting_threads.end(), thread); 22 auto itr = std::find(waiting_threads.begin(), waiting_threads.end(), thread);
22 if (itr == waiting_threads.end()) 23 if (itr == waiting_threads.end())
23 waiting_threads.push_back(std::move(thread)); 24 waiting_threads.push_back(std::move(thread));
24} 25}
25 26
26void WaitObject::RemoveWaitingThread(std::shared_ptr<Thread> thread) { 27void SynchronizationObject::RemoveWaitingThread(std::shared_ptr<Thread> thread) {
27 auto itr = std::find(waiting_threads.begin(), waiting_threads.end(), thread); 28 auto itr = std::find(waiting_threads.begin(), waiting_threads.end(), thread);
28 // If a thread passed multiple handles to the same object, 29 // If a thread passed multiple handles to the same object,
29 // the kernel might attempt to remove the thread from the object's 30 // the kernel might attempt to remove the thread from the object's
@@ -32,7 +33,7 @@ void WaitObject::RemoveWaitingThread(std::shared_ptr<Thread> thread) {
32 waiting_threads.erase(itr); 33 waiting_threads.erase(itr);
33} 34}
34 35
35std::shared_ptr<Thread> WaitObject::GetHighestPriorityReadyThread() const { 36std::shared_ptr<Thread> SynchronizationObject::GetHighestPriorityReadyThread() const {
36 Thread* candidate = nullptr; 37 Thread* candidate = nullptr;
37 u32 candidate_priority = THREADPRIO_LOWEST + 1; 38 u32 candidate_priority = THREADPRIO_LOWEST + 1;
38 39
@@ -57,7 +58,7 @@ std::shared_ptr<Thread> WaitObject::GetHighestPriorityReadyThread() const {
57 return SharedFrom(candidate); 58 return SharedFrom(candidate);
58} 59}
59 60
60void WaitObject::WakeupWaitingThread(std::shared_ptr<Thread> thread) { 61void SynchronizationObject::WakeupWaitingThread(std::shared_ptr<Thread> thread) {
61 ASSERT(!ShouldWait(thread.get())); 62 ASSERT(!ShouldWait(thread.get()));
62 63
63 if (!thread) { 64 if (!thread) {
@@ -65,7 +66,7 @@ void WaitObject::WakeupWaitingThread(std::shared_ptr<Thread> thread) {
65 } 66 }
66 67
67 if (thread->IsSleepingOnWait()) { 68 if (thread->IsSleepingOnWait()) {
68 for (const auto& object : thread->GetWaitObjects()) { 69 for (const auto& object : thread->GetSynchronizationObjects()) {
69 ASSERT(!object->ShouldWait(thread.get())); 70 ASSERT(!object->ShouldWait(thread.get()));
70 object->Acquire(thread.get()); 71 object->Acquire(thread.get());
71 } 72 }
@@ -73,9 +74,9 @@ void WaitObject::WakeupWaitingThread(std::shared_ptr<Thread> thread) {
73 Acquire(thread.get()); 74 Acquire(thread.get());
74 } 75 }
75 76
76 const std::size_t index = thread->GetWaitObjectIndex(SharedFrom(this)); 77 const std::size_t index = thread->GetSynchronizationObjectIndex(SharedFrom(this));
77 78
78 thread->ClearWaitObjects(); 79 thread->ClearSynchronizationObjects();
79 80
80 thread->CancelWakeupTimer(); 81 thread->CancelWakeupTimer();
81 82
@@ -90,13 +91,13 @@ void WaitObject::WakeupWaitingThread(std::shared_ptr<Thread> thread) {
90 } 91 }
91} 92}
92 93
93void WaitObject::WakeupAllWaitingThreads() { 94void SynchronizationObject::WakeupAllWaitingThreads() {
94 while (auto thread = GetHighestPriorityReadyThread()) { 95 while (auto thread = GetHighestPriorityReadyThread()) {
95 WakeupWaitingThread(thread); 96 WakeupWaitingThread(thread);
96 } 97 }
97} 98}
98 99
99const std::vector<std::shared_ptr<Thread>>& WaitObject::GetWaitingThreads() const { 100const std::vector<std::shared_ptr<Thread>>& SynchronizationObject::GetWaitingThreads() const {
100 return waiting_threads; 101 return waiting_threads;
101} 102}
102 103
diff --git a/src/core/hle/kernel/wait_object.h b/src/core/hle/kernel/synchronization_object.h
index 9a17958a4..a0f891c97 100644
--- a/src/core/hle/kernel/wait_object.h
+++ b/src/core/hle/kernel/synchronization_object.h
@@ -15,10 +15,10 @@ class KernelCore;
15class Thread; 15class Thread;
16 16
17/// Class that represents a Kernel object that a thread can be waiting on 17/// Class that represents a Kernel object that a thread can be waiting on
18class WaitObject : public Object { 18class SynchronizationObject : public Object {
19public: 19public:
20 explicit WaitObject(KernelCore& kernel); 20 explicit SynchronizationObject(KernelCore& kernel);
21 ~WaitObject() override; 21 ~SynchronizationObject() override;
22 22
23 /** 23 /**
24 * Check if the specified thread should wait until the object is available 24 * Check if the specified thread should wait until the object is available
@@ -65,11 +65,12 @@ private:
65 std::vector<std::shared_ptr<Thread>> waiting_threads; 65 std::vector<std::shared_ptr<Thread>> waiting_threads;
66}; 66};
67 67
68// Specialization of DynamicObjectCast for WaitObjects 68// Specialization of DynamicObjectCast for SynchronizationObjects
69template <> 69template <>
70inline std::shared_ptr<WaitObject> DynamicObjectCast<WaitObject>(std::shared_ptr<Object> object) { 70inline std::shared_ptr<SynchronizationObject> DynamicObjectCast<SynchronizationObject>(
71 std::shared_ptr<Object> object) {
71 if (object != nullptr && object->IsWaitable()) { 72 if (object != nullptr && object->IsWaitable()) {
72 return std::static_pointer_cast<WaitObject>(object); 73 return std::static_pointer_cast<SynchronizationObject>(object);
73 } 74 }
74 return nullptr; 75 return nullptr;
75} 76}
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index e965b5b04..0f096ed6d 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -35,7 +35,7 @@ void Thread::Acquire(Thread* thread) {
35 ASSERT_MSG(!ShouldWait(thread), "object unavailable!"); 35 ASSERT_MSG(!ShouldWait(thread), "object unavailable!");
36} 36}
37 37
38Thread::Thread(KernelCore& kernel) : WaitObject{kernel} {} 38Thread::Thread(KernelCore& kernel) : SynchronizationObject{kernel} {}
39Thread::~Thread() = default; 39Thread::~Thread() = default;
40 40
41void Thread::Stop() { 41void Thread::Stop() {
@@ -215,7 +215,7 @@ void Thread::SetWaitSynchronizationOutput(s32 output) {
215 context.cpu_registers[1] = output; 215 context.cpu_registers[1] = output;
216} 216}
217 217
218s32 Thread::GetWaitObjectIndex(std::shared_ptr<WaitObject> object) const { 218s32 Thread::GetSynchronizationObjectIndex(std::shared_ptr<SynchronizationObject> object) const {
219 ASSERT_MSG(!wait_objects.empty(), "Thread is not waiting for anything"); 219 ASSERT_MSG(!wait_objects.empty(), "Thread is not waiting for anything");
220 const auto match = std::find(wait_objects.rbegin(), wait_objects.rend(), object); 220 const auto match = std::find(wait_objects.rbegin(), wait_objects.rend(), object);
221 return static_cast<s32>(std::distance(match, wait_objects.rend()) - 1); 221 return static_cast<s32>(std::distance(match, wait_objects.rend()) - 1);
@@ -336,14 +336,16 @@ void Thread::ChangeCore(u32 core, u64 mask) {
336 SetCoreAndAffinityMask(core, mask); 336 SetCoreAndAffinityMask(core, mask);
337} 337}
338 338
339bool Thread::AllWaitObjectsReady() const { 339bool Thread::AllSynchronizationObjectsReady() const {
340 return std::none_of( 340 return std::none_of(wait_objects.begin(), wait_objects.end(),
341 wait_objects.begin(), wait_objects.end(), 341 [this](const std::shared_ptr<SynchronizationObject>& object) {
342 [this](const std::shared_ptr<WaitObject>& object) { return object->ShouldWait(this); }); 342 return object->ShouldWait(this);
343 });
343} 344}
344 345
345bool Thread::InvokeWakeupCallback(ThreadWakeupReason reason, std::shared_ptr<Thread> thread, 346bool Thread::InvokeWakeupCallback(ThreadWakeupReason reason, std::shared_ptr<Thread> thread,
346 std::shared_ptr<WaitObject> object, std::size_t index) { 347 std::shared_ptr<SynchronizationObject> object,
348 std::size_t index) {
347 ASSERT(wakeup_callback); 349 ASSERT(wakeup_callback);
348 return wakeup_callback(reason, std::move(thread), std::move(object), index); 350 return wakeup_callback(reason, std::move(thread), std::move(object), index);
349} 351}
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index 3bcf9e137..895258095 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -11,7 +11,7 @@
11#include "common/common_types.h" 11#include "common/common_types.h"
12#include "core/arm/arm_interface.h" 12#include "core/arm/arm_interface.h"
13#include "core/hle/kernel/object.h" 13#include "core/hle/kernel/object.h"
14#include "core/hle/kernel/wait_object.h" 14#include "core/hle/kernel/synchronization_object.h"
15#include "core/hle/result.h" 15#include "core/hle/result.h"
16 16
17namespace Kernel { 17namespace Kernel {
@@ -95,7 +95,7 @@ enum class ThreadSchedMasks : u32 {
95 ForcePauseMask = 0x0070, 95 ForcePauseMask = 0x0070,
96}; 96};
97 97
98class Thread final : public WaitObject { 98class Thread final : public SynchronizationObject {
99public: 99public:
100 explicit Thread(KernelCore& kernel); 100 explicit Thread(KernelCore& kernel);
101 ~Thread() override; 101 ~Thread() override;
@@ -104,11 +104,11 @@ public:
104 104
105 using ThreadContext = Core::ARM_Interface::ThreadContext; 105 using ThreadContext = Core::ARM_Interface::ThreadContext;
106 106
107 using ThreadWaitObjects = std::vector<std::shared_ptr<WaitObject>>; 107 using ThreadSynchronizationObjects = std::vector<std::shared_ptr<SynchronizationObject>>;
108 108
109 using WakeupCallback = 109 using WakeupCallback =
110 std::function<bool(ThreadWakeupReason reason, std::shared_ptr<Thread> thread, 110 std::function<bool(ThreadWakeupReason reason, std::shared_ptr<Thread> thread,
111 std::shared_ptr<WaitObject> object, std::size_t index)>; 111 std::shared_ptr<SynchronizationObject> object, std::size_t index)>;
112 112
113 /** 113 /**
114 * Creates and returns a new thread. The new thread is immediately scheduled 114 * Creates and returns a new thread. The new thread is immediately scheduled
@@ -233,7 +233,7 @@ public:
233 * 233 *
234 * @param object Object to query the index of. 234 * @param object Object to query the index of.
235 */ 235 */
236 s32 GetWaitObjectIndex(std::shared_ptr<WaitObject> object) const; 236 s32 GetSynchronizationObjectIndex(std::shared_ptr<SynchronizationObject> object) const;
237 237
238 /** 238 /**
239 * Stops a thread, invalidating it from further use 239 * Stops a thread, invalidating it from further use
@@ -314,15 +314,15 @@ public:
314 return owner_process; 314 return owner_process;
315 } 315 }
316 316
317 const ThreadWaitObjects& GetWaitObjects() const { 317 const ThreadSynchronizationObjects& GetSynchronizationObjects() const {
318 return wait_objects; 318 return wait_objects;
319 } 319 }
320 320
321 void SetWaitObjects(ThreadWaitObjects objects) { 321 void SetSynchronizationObjects(ThreadSynchronizationObjects objects) {
322 wait_objects = std::move(objects); 322 wait_objects = std::move(objects);
323 } 323 }
324 324
325 void ClearWaitObjects() { 325 void ClearSynchronizationObjects() {
326 for (const auto& waiting_object : wait_objects) { 326 for (const auto& waiting_object : wait_objects) {
327 waiting_object->RemoveWaitingThread(SharedFrom(this)); 327 waiting_object->RemoveWaitingThread(SharedFrom(this));
328 } 328 }
@@ -330,7 +330,7 @@ public:
330 } 330 }
331 331
332 /// Determines whether all the objects this thread is waiting on are ready. 332 /// Determines whether all the objects this thread is waiting on are ready.
333 bool AllWaitObjectsReady() const; 333 bool AllSynchronizationObjectsReady() const;
334 334
335 const MutexWaitingThreads& GetMutexWaitingThreads() const { 335 const MutexWaitingThreads& GetMutexWaitingThreads() const {
336 return wait_mutex_threads; 336 return wait_mutex_threads;
@@ -395,7 +395,7 @@ public:
395 * will cause an assertion to trigger. 395 * will cause an assertion to trigger.
396 */ 396 */
397 bool InvokeWakeupCallback(ThreadWakeupReason reason, std::shared_ptr<Thread> thread, 397 bool InvokeWakeupCallback(ThreadWakeupReason reason, std::shared_ptr<Thread> thread,
398 std::shared_ptr<WaitObject> object, std::size_t index); 398 std::shared_ptr<SynchronizationObject> object, std::size_t index);
399 399
400 u32 GetIdealCore() const { 400 u32 GetIdealCore() const {
401 return ideal_core; 401 return ideal_core;
@@ -494,7 +494,7 @@ private:
494 494
495 /// Objects that the thread is waiting on, in the same order as they were 495 /// Objects that the thread is waiting on, in the same order as they were
496 /// passed to WaitSynchronization. 496 /// passed to WaitSynchronization.
497 ThreadWaitObjects wait_objects; 497 ThreadSynchronizationObjects wait_objects;
498 498
499 /// List of threads that are waiting for a mutex that is held by this thread. 499 /// List of threads that are waiting for a mutex that is held by this thread.
500 MutexWaitingThreads wait_mutex_threads; 500 MutexWaitingThreads wait_mutex_threads;