From 73fba22c019562687c6e14f20ca7422020f7e070 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 13 Dec 2014 21:16:13 -0200 Subject: Rename ObjectPool to HandleTable --- src/core/hle/kernel/thread.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/core/hle/kernel/thread.cpp') diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index c6a8dc7b9..c89d9433a 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -164,7 +164,7 @@ static bool CheckWaitType(const Thread* thread, WaitType type, Handle wait_handl /// Stops the current thread ResultCode StopThread(Handle handle, const char* reason) { - Thread* thread = g_object_pool.Get(handle); + Thread* thread = g_handle_table.Get(handle); if (thread == nullptr) return InvalidHandle(ErrorModule::Kernel); // Release all the mutexes that this thread holds @@ -173,7 +173,7 @@ ResultCode StopThread(Handle handle, const char* reason) { ChangeReadyState(thread, false); thread->status = THREADSTATUS_DORMANT; for (Handle waiting_handle : thread->waiting_threads) { - Thread* waiting_thread = g_object_pool.Get(waiting_handle); + Thread* waiting_thread = g_handle_table.Get(waiting_handle); if (CheckWaitType(waiting_thread, WAITTYPE_THREADEND, handle)) ResumeThreadFromWait(waiting_handle); @@ -210,7 +210,7 @@ Handle ArbitrateHighestPriorityThread(u32 arbiter, u32 address) { // Iterate through threads, find highest priority thread that is waiting to be arbitrated... for (Handle handle : thread_queue) { - Thread* thread = g_object_pool.Get(handle); + Thread* thread = g_handle_table.Get(handle); if (!CheckWaitType(thread, WAITTYPE_ARB, arbiter, address)) continue; @@ -235,7 +235,7 @@ void ArbitrateAllThreads(u32 arbiter, u32 address) { // Iterate through threads, find highest priority thread that is waiting to be arbitrated... for (Handle handle : thread_queue) { - Thread* thread = g_object_pool.Get(handle); + Thread* thread = g_handle_table.Get(handle); if (CheckWaitType(thread, WAITTYPE_ARB, arbiter, address)) ResumeThreadFromWait(handle); @@ -288,7 +288,7 @@ Thread* NextThread() { if (next == 0) { return nullptr; } - return Kernel::g_object_pool.Get(next); + return Kernel::g_handle_table.Get(next); } void WaitCurrentThread(WaitType wait_type, Handle wait_handle) { @@ -305,7 +305,7 @@ void WaitCurrentThread(WaitType wait_type, Handle wait_handle, VAddr wait_addres /// Resumes a thread from waiting by marking it as "ready" void ResumeThreadFromWait(Handle handle) { - Thread* thread = Kernel::g_object_pool.Get(handle); + Thread* thread = Kernel::g_handle_table.Get(handle); if (thread) { thread->status &= ~THREADSTATUS_WAIT; thread->wait_handle = 0; @@ -341,7 +341,7 @@ Thread* CreateThread(Handle& handle, const char* name, u32 entry_point, s32 prio Thread* thread = new Thread; - handle = Kernel::g_object_pool.Create(thread); + handle = Kernel::g_handle_table.Create(thread); thread_queue.push_back(handle); thread_ready_queue.prepare(priority); @@ -398,7 +398,7 @@ Handle CreateThread(const char* name, u32 entry_point, s32 priority, u32 arg, s3 /// Get the priority of the thread specified by handle ResultVal GetThreadPriority(const Handle handle) { - Thread* thread = g_object_pool.Get(handle); + Thread* thread = g_handle_table.Get(handle); if (thread == nullptr) return InvalidHandle(ErrorModule::Kernel); return MakeResult(thread->current_priority); @@ -410,7 +410,7 @@ ResultCode SetThreadPriority(Handle handle, s32 priority) { if (!handle) { thread = GetCurrentThread(); // TODO(bunnei): Is this correct behavior? } else { - thread = g_object_pool.Get(handle); + thread = g_handle_table.Get(handle); if (thread == nullptr) { return InvalidHandle(ErrorModule::Kernel); } @@ -481,7 +481,7 @@ void Reschedule() { LOG_TRACE(Kernel, "cannot context switch from 0x%08X, no higher priority thread!", prev->GetHandle()); for (Handle handle : thread_queue) { - Thread* thread = g_object_pool.Get(handle); + Thread* thread = g_handle_table.Get(handle); LOG_TRACE(Kernel, "\thandle=0x%08X prio=0x%02X, status=0x%08X wait_type=0x%08X wait_handle=0x%08X", thread->GetHandle(), thread->current_priority, thread->status, thread->wait_type, thread->wait_handle); } @@ -497,7 +497,7 @@ void Reschedule() { } ResultCode GetThreadId(u32* thread_id, Handle handle) { - Thread* thread = g_object_pool.Get(handle); + Thread* thread = g_handle_table.Get(handle); if (thread == nullptr) return ResultCode(ErrorDescription::InvalidHandle, ErrorModule::OS, ErrorSummary::WrongArgument, ErrorLevel::Permanent); -- cgit v1.2.3 From 23f2142009e45b227867cefe40dfe9d338625974 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sun, 21 Dec 2014 08:40:29 -0200 Subject: Kernel: Replace GetStaticHandleType by HANDLE_TYPE constants --- src/core/hle/kernel/thread.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core/hle/kernel/thread.cpp') diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index c89d9433a..2739bdd52 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -26,8 +26,8 @@ public: std::string GetName() const override { return name; } std::string GetTypeName() const override { return "Thread"; } - static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Thread; } - Kernel::HandleType GetHandleType() const override { return Kernel::HandleType::Thread; } + static const HandleType HANDLE_TYPE = HandleType::Thread; + HandleType GetHandleType() const override { return HANDLE_TYPE; } inline bool IsRunning() const { return (status & THREADSTATUS_RUNNING) != 0; } inline bool IsStopped() const { return (status & THREADSTATUS_DORMANT) != 0; } -- cgit v1.2.3 From 7e2903cb74050d846f2da951dff7e84aee13761b Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sun, 21 Dec 2014 10:04:08 -0200 Subject: Kernel: New handle manager This handle manager more closely mirrors the behaviour of the CTR-OS one. In addition object ref-counts and support for DuplicateHandle have been added. Note that support for DuplicateHandle is still experimental, since parts of the kernel still use Handles internally, which will likely cause troubles if two different handles to the same object are used to e.g. wait on a synchronization primitive. --- src/core/hle/kernel/thread.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/core/hle/kernel/thread.cpp') diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 2739bdd52..872df2d14 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -341,7 +341,8 @@ Thread* CreateThread(Handle& handle, const char* name, u32 entry_point, s32 prio Thread* thread = new Thread; - handle = Kernel::g_handle_table.Create(thread); + // TOOD(yuriks): Fix error reporting + handle = Kernel::g_handle_table.Create(thread).ValueOr(INVALID_HANDLE); thread_queue.push_back(handle); thread_ready_queue.prepare(priority); -- cgit v1.2.3