diff options
| author | 2020-12-30 23:01:08 -0800 | |
|---|---|---|
| committer | 2021-01-28 21:42:25 -0800 | |
| commit | c0d3aef28c0a0c68c18de30228f29e30f0e52533 (patch) | |
| tree | 2f94a5f6e5fec4d288272f9a476ee85a8da3d0ac | |
| parent | Merge pull request #5837 from german77/socketstub (diff) | |
| download | yuzu-c0d3aef28c0a0c68c18de30228f29e30f0e52533.tar.gz yuzu-c0d3aef28c0a0c68c18de30228f29e30f0e52533.tar.xz yuzu-c0d3aef28c0a0c68c18de30228f29e30f0e52533.zip | |
core: hle: kernel: Rename Thread to KThread.
45 files changed, 271 insertions, 272 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 9c9b3195b..88a31e0f2 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -168,6 +168,8 @@ add_library(core STATIC | |||
| 168 | hle/kernel/k_scoped_scheduler_lock_and_sleep.h | 168 | hle/kernel/k_scoped_scheduler_lock_and_sleep.h |
| 169 | hle/kernel/k_synchronization_object.cpp | 169 | hle/kernel/k_synchronization_object.cpp |
| 170 | hle/kernel/k_synchronization_object.h | 170 | hle/kernel/k_synchronization_object.h |
| 171 | hle/kernel/k_thread.cpp | ||
| 172 | hle/kernel/k_thread.h | ||
| 171 | hle/kernel/kernel.cpp | 173 | hle/kernel/kernel.cpp |
| 172 | hle/kernel/kernel.h | 174 | hle/kernel/kernel.h |
| 173 | hle/kernel/memory/address_space_info.cpp | 175 | hle/kernel/memory/address_space_info.cpp |
| @@ -216,8 +218,6 @@ add_library(core STATIC | |||
| 216 | hle/kernel/svc_results.h | 218 | hle/kernel/svc_results.h |
| 217 | hle/kernel/svc_types.h | 219 | hle/kernel/svc_types.h |
| 218 | hle/kernel/svc_wrap.h | 220 | hle/kernel/svc_wrap.h |
| 219 | hle/kernel/thread.cpp | ||
| 220 | hle/kernel/thread.h | ||
| 221 | hle/kernel/time_manager.cpp | 221 | hle/kernel/time_manager.cpp |
| 222 | hle/kernel/time_manager.h | 222 | hle/kernel/time_manager.h |
| 223 | hle/kernel/transfer_memory.cpp | 223 | hle/kernel/transfer_memory.cpp |
diff --git a/src/core/core.cpp b/src/core/core.cpp index 86bdc7f6b..30f5e1128 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -28,10 +28,10 @@ | |||
| 28 | #include "core/hardware_interrupt_manager.h" | 28 | #include "core/hardware_interrupt_manager.h" |
| 29 | #include "core/hle/kernel/client_port.h" | 29 | #include "core/hle/kernel/client_port.h" |
| 30 | #include "core/hle/kernel/k_scheduler.h" | 30 | #include "core/hle/kernel/k_scheduler.h" |
| 31 | #include "core/hle/kernel/k_thread.h" | ||
| 31 | #include "core/hle/kernel/kernel.h" | 32 | #include "core/hle/kernel/kernel.h" |
| 32 | #include "core/hle/kernel/physical_core.h" | 33 | #include "core/hle/kernel/physical_core.h" |
| 33 | #include "core/hle/kernel/process.h" | 34 | #include "core/hle/kernel/process.h" |
| 34 | #include "core/hle/kernel/thread.h" | ||
| 35 | #include "core/hle/service/am/applets/applets.h" | 35 | #include "core/hle/service/am/applets/applets.h" |
| 36 | #include "core/hle/service/apm/controller.h" | 36 | #include "core/hle/service/apm/controller.h" |
| 37 | #include "core/hle/service/filesystem/filesystem.h" | 37 | #include "core/hle/service/filesystem/filesystem.h" |
diff --git a/src/core/cpu_manager.cpp b/src/core/cpu_manager.cpp index 373395047..122edb588 100644 --- a/src/core/cpu_manager.cpp +++ b/src/core/cpu_manager.cpp | |||
| @@ -11,9 +11,9 @@ | |||
| 11 | #include "core/core_timing.h" | 11 | #include "core/core_timing.h" |
| 12 | #include "core/cpu_manager.h" | 12 | #include "core/cpu_manager.h" |
| 13 | #include "core/hle/kernel/k_scheduler.h" | 13 | #include "core/hle/kernel/k_scheduler.h" |
| 14 | #include "core/hle/kernel/k_thread.h" | ||
| 14 | #include "core/hle/kernel/kernel.h" | 15 | #include "core/hle/kernel/kernel.h" |
| 15 | #include "core/hle/kernel/physical_core.h" | 16 | #include "core/hle/kernel/physical_core.h" |
| 16 | #include "core/hle/kernel/thread.h" | ||
| 17 | #include "video_core/gpu.h" | 17 | #include "video_core/gpu.h" |
| 18 | 18 | ||
| 19 | namespace Core { | 19 | namespace Core { |
| @@ -147,7 +147,7 @@ void CpuManager::MultiCoreRunSuspendThread() { | |||
| 147 | while (true) { | 147 | while (true) { |
| 148 | auto core = kernel.GetCurrentHostThreadID(); | 148 | auto core = kernel.GetCurrentHostThreadID(); |
| 149 | auto& scheduler = *kernel.CurrentScheduler(); | 149 | auto& scheduler = *kernel.CurrentScheduler(); |
| 150 | Kernel::Thread* current_thread = scheduler.GetCurrentThread(); | 150 | Kernel::KThread* current_thread = scheduler.GetCurrentThread(); |
| 151 | Common::Fiber::YieldTo(current_thread->GetHostContext(), core_data[core].host_context); | 151 | Common::Fiber::YieldTo(current_thread->GetHostContext(), core_data[core].host_context); |
| 152 | ASSERT(scheduler.ContextSwitchPending()); | 152 | ASSERT(scheduler.ContextSwitchPending()); |
| 153 | ASSERT(core == kernel.GetCurrentHostThreadID()); | 153 | ASSERT(core == kernel.GetCurrentHostThreadID()); |
| @@ -245,7 +245,7 @@ void CpuManager::SingleCoreRunSuspendThread() { | |||
| 245 | while (true) { | 245 | while (true) { |
| 246 | auto core = kernel.GetCurrentHostThreadID(); | 246 | auto core = kernel.GetCurrentHostThreadID(); |
| 247 | auto& scheduler = *kernel.CurrentScheduler(); | 247 | auto& scheduler = *kernel.CurrentScheduler(); |
| 248 | Kernel::Thread* current_thread = scheduler.GetCurrentThread(); | 248 | Kernel::KThread* current_thread = scheduler.GetCurrentThread(); |
| 249 | Common::Fiber::YieldTo(current_thread->GetHostContext(), core_data[0].host_context); | 249 | Common::Fiber::YieldTo(current_thread->GetHostContext(), core_data[0].host_context); |
| 250 | ASSERT(scheduler.ContextSwitchPending()); | 250 | ASSERT(scheduler.ContextSwitchPending()); |
| 251 | ASSERT(core == kernel.GetCurrentHostThreadID()); | 251 | ASSERT(core == kernel.GetCurrentHostThreadID()); |
| @@ -256,7 +256,7 @@ void CpuManager::SingleCoreRunSuspendThread() { | |||
| 256 | void CpuManager::PreemptSingleCore(bool from_running_enviroment) { | 256 | void CpuManager::PreemptSingleCore(bool from_running_enviroment) { |
| 257 | { | 257 | { |
| 258 | auto& scheduler = system.Kernel().Scheduler(current_core); | 258 | auto& scheduler = system.Kernel().Scheduler(current_core); |
| 259 | Kernel::Thread* current_thread = scheduler.GetCurrentThread(); | 259 | Kernel::KThread* current_thread = scheduler.GetCurrentThread(); |
| 260 | if (idle_count >= 4 || from_running_enviroment) { | 260 | if (idle_count >= 4 || from_running_enviroment) { |
| 261 | if (!from_running_enviroment) { | 261 | if (!from_running_enviroment) { |
| 262 | system.CoreTiming().Idle(); | 262 | system.CoreTiming().Idle(); |
diff --git a/src/core/hle/kernel/client_session.cpp b/src/core/hle/kernel/client_session.cpp index e8e52900d..a2be1a8f6 100644 --- a/src/core/hle/kernel/client_session.cpp +++ b/src/core/hle/kernel/client_session.cpp | |||
| @@ -5,9 +5,9 @@ | |||
| 5 | #include "core/hle/kernel/client_session.h" | 5 | #include "core/hle/kernel/client_session.h" |
| 6 | #include "core/hle/kernel/errors.h" | 6 | #include "core/hle/kernel/errors.h" |
| 7 | #include "core/hle/kernel/hle_ipc.h" | 7 | #include "core/hle/kernel/hle_ipc.h" |
| 8 | #include "core/hle/kernel/k_thread.h" | ||
| 8 | #include "core/hle/kernel/server_session.h" | 9 | #include "core/hle/kernel/server_session.h" |
| 9 | #include "core/hle/kernel/session.h" | 10 | #include "core/hle/kernel/session.h" |
| 10 | #include "core/hle/kernel/thread.h" | ||
| 11 | #include "core/hle/result.h" | 11 | #include "core/hle/result.h" |
| 12 | 12 | ||
| 13 | namespace Kernel { | 13 | namespace Kernel { |
| @@ -38,7 +38,7 @@ ResultVal<std::shared_ptr<ClientSession>> ClientSession::Create(KernelCore& kern | |||
| 38 | return MakeResult(std::move(client_session)); | 38 | return MakeResult(std::move(client_session)); |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | ResultCode ClientSession::SendSyncRequest(std::shared_ptr<Thread> thread, | 41 | ResultCode ClientSession::SendSyncRequest(std::shared_ptr<KThread> thread, |
| 42 | Core::Memory::Memory& memory, | 42 | Core::Memory::Memory& memory, |
| 43 | Core::Timing::CoreTiming& core_timing) { | 43 | Core::Timing::CoreTiming& core_timing) { |
| 44 | // Keep ServerSession alive until we're done working with it. | 44 | // Keep ServerSession alive until we're done working with it. |
diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h index d5c9ebee8..a914c0990 100644 --- a/src/core/hle/kernel/client_session.h +++ b/src/core/hle/kernel/client_session.h | |||
| @@ -24,7 +24,7 @@ namespace Kernel { | |||
| 24 | 24 | ||
| 25 | class KernelCore; | 25 | class KernelCore; |
| 26 | class Session; | 26 | class Session; |
| 27 | class Thread; | 27 | class KThread; |
| 28 | 28 | ||
| 29 | class ClientSession final : public KSynchronizationObject { | 29 | class ClientSession final : public KSynchronizationObject { |
| 30 | public: | 30 | public: |
| @@ -46,7 +46,7 @@ public: | |||
| 46 | return HANDLE_TYPE; | 46 | return HANDLE_TYPE; |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | ResultCode SendSyncRequest(std::shared_ptr<Thread> thread, Core::Memory::Memory& memory, | 49 | ResultCode SendSyncRequest(std::shared_ptr<KThread> thread, Core::Memory::Memory& memory, |
| 50 | Core::Timing::CoreTiming& core_timing); | 50 | Core::Timing::CoreTiming& core_timing); |
| 51 | 51 | ||
| 52 | bool IsSignaled() const override; | 52 | bool IsSignaled() const override; |
diff --git a/src/core/hle/kernel/global_scheduler_context.cpp b/src/core/hle/kernel/global_scheduler_context.cpp index a133e8ed0..c6838649f 100644 --- a/src/core/hle/kernel/global_scheduler_context.cpp +++ b/src/core/hle/kernel/global_scheduler_context.cpp | |||
| @@ -17,12 +17,12 @@ GlobalSchedulerContext::GlobalSchedulerContext(KernelCore& kernel) | |||
| 17 | 17 | ||
| 18 | GlobalSchedulerContext::~GlobalSchedulerContext() = default; | 18 | GlobalSchedulerContext::~GlobalSchedulerContext() = default; |
| 19 | 19 | ||
| 20 | void GlobalSchedulerContext::AddThread(std::shared_ptr<Thread> thread) { | 20 | void GlobalSchedulerContext::AddThread(std::shared_ptr<KThread> thread) { |
| 21 | std::scoped_lock lock{global_list_guard}; | 21 | std::scoped_lock lock{global_list_guard}; |
| 22 | thread_list.push_back(std::move(thread)); | 22 | thread_list.push_back(std::move(thread)); |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | void GlobalSchedulerContext::RemoveThread(std::shared_ptr<Thread> thread) { | 25 | void GlobalSchedulerContext::RemoveThread(std::shared_ptr<KThread> thread) { |
| 26 | std::scoped_lock lock{global_list_guard}; | 26 | std::scoped_lock lock{global_list_guard}; |
| 27 | thread_list.erase(std::remove(thread_list.begin(), thread_list.end(), thread), | 27 | thread_list.erase(std::remove(thread_list.begin(), thread_list.end(), thread), |
| 28 | thread_list.end()); | 28 | thread_list.end()); |
diff --git a/src/core/hle/kernel/global_scheduler_context.h b/src/core/hle/kernel/global_scheduler_context.h index 5c7b89290..a365ffdaf 100644 --- a/src/core/hle/kernel/global_scheduler_context.h +++ b/src/core/hle/kernel/global_scheduler_context.h | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | #include "core/hardware_properties.h" | 12 | #include "core/hardware_properties.h" |
| 13 | #include "core/hle/kernel/k_priority_queue.h" | 13 | #include "core/hle/kernel/k_priority_queue.h" |
| 14 | #include "core/hle/kernel/k_scheduler_lock.h" | 14 | #include "core/hle/kernel/k_scheduler_lock.h" |
| 15 | #include "core/hle/kernel/thread.h" | 15 | #include "core/hle/kernel/k_thread.h" |
| 16 | 16 | ||
| 17 | namespace Kernel { | 17 | namespace Kernel { |
| 18 | 18 | ||
| @@ -20,7 +20,7 @@ class KernelCore; | |||
| 20 | class SchedulerLock; | 20 | class SchedulerLock; |
| 21 | 21 | ||
| 22 | using KSchedulerPriorityQueue = | 22 | using KSchedulerPriorityQueue = |
| 23 | KPriorityQueue<Thread, Core::Hardware::NUM_CPU_CORES, THREADPRIO_LOWEST, THREADPRIO_HIGHEST>; | 23 | KPriorityQueue<KThread, Core::Hardware::NUM_CPU_CORES, THREADPRIO_LOWEST, THREADPRIO_HIGHEST>; |
| 24 | constexpr s32 HighestCoreMigrationAllowedPriority = 2; | 24 | constexpr s32 HighestCoreMigrationAllowedPriority = 2; |
| 25 | 25 | ||
| 26 | class GlobalSchedulerContext final { | 26 | class GlobalSchedulerContext final { |
| @@ -33,13 +33,13 @@ public: | |||
| 33 | ~GlobalSchedulerContext(); | 33 | ~GlobalSchedulerContext(); |
| 34 | 34 | ||
| 35 | /// Adds a new thread to the scheduler | 35 | /// Adds a new thread to the scheduler |
| 36 | void AddThread(std::shared_ptr<Thread> thread); | 36 | void AddThread(std::shared_ptr<KThread> thread); |
| 37 | 37 | ||
| 38 | /// Removes a thread from the scheduler | 38 | /// Removes a thread from the scheduler |
| 39 | void RemoveThread(std::shared_ptr<Thread> thread); | 39 | void RemoveThread(std::shared_ptr<KThread> thread); |
| 40 | 40 | ||
| 41 | /// Returns a list of all threads managed by the scheduler | 41 | /// Returns a list of all threads managed by the scheduler |
| 42 | [[nodiscard]] const std::vector<std::shared_ptr<Thread>>& GetThreadList() const { | 42 | [[nodiscard]] const std::vector<std::shared_ptr<KThread>>& GetThreadList() const { |
| 43 | return thread_list; | 43 | return thread_list; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| @@ -74,7 +74,7 @@ private: | |||
| 74 | LockType scheduler_lock; | 74 | LockType scheduler_lock; |
| 75 | 75 | ||
| 76 | /// Lists all thread ids that aren't deleted/etc. | 76 | /// Lists all thread ids that aren't deleted/etc. |
| 77 | std::vector<std::shared_ptr<Thread>> thread_list; | 77 | std::vector<std::shared_ptr<KThread>> thread_list; |
| 78 | Common::SpinLock global_list_guard{}; | 78 | Common::SpinLock global_list_guard{}; |
| 79 | }; | 79 | }; |
| 80 | 80 | ||
diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp index 40988b0fd..10a4e0510 100644 --- a/src/core/hle/kernel/handle_table.cpp +++ b/src/core/hle/kernel/handle_table.cpp | |||
| @@ -9,9 +9,9 @@ | |||
| 9 | #include "core/hle/kernel/errors.h" | 9 | #include "core/hle/kernel/errors.h" |
| 10 | #include "core/hle/kernel/handle_table.h" | 10 | #include "core/hle/kernel/handle_table.h" |
| 11 | #include "core/hle/kernel/k_scheduler.h" | 11 | #include "core/hle/kernel/k_scheduler.h" |
| 12 | #include "core/hle/kernel/k_thread.h" | ||
| 12 | #include "core/hle/kernel/kernel.h" | 13 | #include "core/hle/kernel/kernel.h" |
| 13 | #include "core/hle/kernel/process.h" | 14 | #include "core/hle/kernel/process.h" |
| 14 | #include "core/hle/kernel/thread.h" | ||
| 15 | 15 | ||
| 16 | namespace Kernel { | 16 | namespace Kernel { |
| 17 | namespace { | 17 | namespace { |
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index a419f9602..c7b10ca7a 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp | |||
| @@ -19,12 +19,12 @@ | |||
| 19 | #include "core/hle/kernel/hle_ipc.h" | 19 | #include "core/hle/kernel/hle_ipc.h" |
| 20 | #include "core/hle/kernel/k_scheduler.h" | 20 | #include "core/hle/kernel/k_scheduler.h" |
| 21 | #include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h" | 21 | #include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h" |
| 22 | #include "core/hle/kernel/k_thread.h" | ||
| 22 | #include "core/hle/kernel/kernel.h" | 23 | #include "core/hle/kernel/kernel.h" |
| 23 | #include "core/hle/kernel/object.h" | 24 | #include "core/hle/kernel/object.h" |
| 24 | #include "core/hle/kernel/process.h" | 25 | #include "core/hle/kernel/process.h" |
| 25 | #include "core/hle/kernel/readable_event.h" | 26 | #include "core/hle/kernel/readable_event.h" |
| 26 | #include "core/hle/kernel/server_session.h" | 27 | #include "core/hle/kernel/server_session.h" |
| 27 | #include "core/hle/kernel/thread.h" | ||
| 28 | #include "core/hle/kernel/time_manager.h" | 28 | #include "core/hle/kernel/time_manager.h" |
| 29 | #include "core/hle/kernel/writable_event.h" | 29 | #include "core/hle/kernel/writable_event.h" |
| 30 | #include "core/memory.h" | 30 | #include "core/memory.h" |
| @@ -48,7 +48,7 @@ void SessionRequestHandler::ClientDisconnected( | |||
| 48 | 48 | ||
| 49 | HLERequestContext::HLERequestContext(KernelCore& kernel, Core::Memory::Memory& memory, | 49 | HLERequestContext::HLERequestContext(KernelCore& kernel, Core::Memory::Memory& memory, |
| 50 | std::shared_ptr<ServerSession> server_session, | 50 | std::shared_ptr<ServerSession> server_session, |
| 51 | std::shared_ptr<Thread> thread) | 51 | std::shared_ptr<KThread> thread) |
| 52 | : server_session(std::move(server_session)), | 52 | : server_session(std::move(server_session)), |
| 53 | thread(std::move(thread)), kernel{kernel}, memory{memory} { | 53 | thread(std::move(thread)), kernel{kernel}, memory{memory} { |
| 54 | cmd_buf[0] = 0; | 54 | cmd_buf[0] = 0; |
| @@ -182,7 +182,7 @@ ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(const HandleTabl | |||
| 182 | return RESULT_SUCCESS; | 182 | return RESULT_SUCCESS; |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(Thread& thread) { | 185 | ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(KThread& thread) { |
| 186 | auto& owner_process = *thread.GetOwnerProcess(); | 186 | auto& owner_process = *thread.GetOwnerProcess(); |
| 187 | auto& handle_table = owner_process.GetHandleTable(); | 187 | auto& handle_table = owner_process.GetHandleTable(); |
| 188 | 188 | ||
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index 698f607e6..b8a746882 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h | |||
| @@ -40,7 +40,7 @@ class HLERequestContext; | |||
| 40 | class KernelCore; | 40 | class KernelCore; |
| 41 | class Process; | 41 | class Process; |
| 42 | class ServerSession; | 42 | class ServerSession; |
| 43 | class Thread; | 43 | class KThread; |
| 44 | class ReadableEvent; | 44 | class ReadableEvent; |
| 45 | class WritableEvent; | 45 | class WritableEvent; |
| 46 | 46 | ||
| @@ -110,7 +110,7 @@ class HLERequestContext { | |||
| 110 | public: | 110 | public: |
| 111 | explicit HLERequestContext(KernelCore& kernel, Core::Memory::Memory& memory, | 111 | explicit HLERequestContext(KernelCore& kernel, Core::Memory::Memory& memory, |
| 112 | std::shared_ptr<ServerSession> session, | 112 | std::shared_ptr<ServerSession> session, |
| 113 | std::shared_ptr<Thread> thread); | 113 | std::shared_ptr<KThread> thread); |
| 114 | ~HLERequestContext(); | 114 | ~HLERequestContext(); |
| 115 | 115 | ||
| 116 | /// Returns a pointer to the IPC command buffer for this request. | 116 | /// Returns a pointer to the IPC command buffer for this request. |
| @@ -127,14 +127,14 @@ public: | |||
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | using WakeupCallback = std::function<void( | 129 | using WakeupCallback = std::function<void( |
| 130 | std::shared_ptr<Thread> thread, HLERequestContext& context, ThreadWakeupReason reason)>; | 130 | std::shared_ptr<KThread> thread, HLERequestContext& context, ThreadWakeupReason reason)>; |
| 131 | 131 | ||
| 132 | /// Populates this context with data from the requesting process/thread. | 132 | /// Populates this context with data from the requesting process/thread. |
| 133 | ResultCode PopulateFromIncomingCommandBuffer(const HandleTable& handle_table, | 133 | ResultCode PopulateFromIncomingCommandBuffer(const HandleTable& handle_table, |
| 134 | u32_le* src_cmdbuf); | 134 | u32_le* src_cmdbuf); |
| 135 | 135 | ||
| 136 | /// Writes data from this context back to the requesting process/thread. | 136 | /// Writes data from this context back to the requesting process/thread. |
| 137 | ResultCode WriteToOutgoingCommandBuffer(Thread& thread); | 137 | ResultCode WriteToOutgoingCommandBuffer(KThread& thread); |
| 138 | 138 | ||
| 139 | u32_le GetCommand() const { | 139 | u32_le GetCommand() const { |
| 140 | return command; | 140 | return command; |
| @@ -267,11 +267,11 @@ public: | |||
| 267 | 267 | ||
| 268 | std::string Description() const; | 268 | std::string Description() const; |
| 269 | 269 | ||
| 270 | Thread& GetThread() { | 270 | KThread& GetThread() { |
| 271 | return *thread; | 271 | return *thread; |
| 272 | } | 272 | } |
| 273 | 273 | ||
| 274 | const Thread& GetThread() const { | 274 | const KThread& GetThread() const { |
| 275 | return *thread; | 275 | return *thread; |
| 276 | } | 276 | } |
| 277 | 277 | ||
| @@ -286,7 +286,7 @@ private: | |||
| 286 | 286 | ||
| 287 | std::array<u32, IPC::COMMAND_BUFFER_LENGTH> cmd_buf; | 287 | std::array<u32, IPC::COMMAND_BUFFER_LENGTH> cmd_buf; |
| 288 | std::shared_ptr<Kernel::ServerSession> server_session; | 288 | std::shared_ptr<Kernel::ServerSession> server_session; |
| 289 | std::shared_ptr<Thread> thread; | 289 | std::shared_ptr<KThread> thread; |
| 290 | // TODO(yuriks): Check common usage of this and optimize size accordingly | 290 | // TODO(yuriks): Check common usage of this and optimize size accordingly |
| 291 | boost::container::small_vector<std::shared_ptr<Object>, 8> move_objects; | 291 | boost::container::small_vector<std::shared_ptr<Object>, 8> move_objects; |
| 292 | boost::container::small_vector<std::shared_ptr<Object>, 8> copy_objects; | 292 | boost::container::small_vector<std::shared_ptr<Object>, 8> copy_objects; |
diff --git a/src/core/hle/kernel/k_address_arbiter.cpp b/src/core/hle/kernel/k_address_arbiter.cpp index d9e702f13..282f02257 100644 --- a/src/core/hle/kernel/k_address_arbiter.cpp +++ b/src/core/hle/kernel/k_address_arbiter.cpp | |||
| @@ -7,9 +7,9 @@ | |||
| 7 | #include "core/hle/kernel/k_address_arbiter.h" | 7 | #include "core/hle/kernel/k_address_arbiter.h" |
| 8 | #include "core/hle/kernel/k_scheduler.h" | 8 | #include "core/hle/kernel/k_scheduler.h" |
| 9 | #include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h" | 9 | #include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h" |
| 10 | #include "core/hle/kernel/k_thread.h" | ||
| 10 | #include "core/hle/kernel/kernel.h" | 11 | #include "core/hle/kernel/kernel.h" |
| 11 | #include "core/hle/kernel/svc_results.h" | 12 | #include "core/hle/kernel/svc_results.h" |
| 12 | #include "core/hle/kernel/thread.h" | ||
| 13 | #include "core/hle/kernel/time_manager.h" | 13 | #include "core/hle/kernel/time_manager.h" |
| 14 | #include "core/memory.h" | 14 | #include "core/memory.h" |
| 15 | 15 | ||
| @@ -96,7 +96,7 @@ ResultCode KAddressArbiter::Signal(VAddr addr, s32 count) { | |||
| 96 | auto it = thread_tree.nfind_light({addr, -1}); | 96 | auto it = thread_tree.nfind_light({addr, -1}); |
| 97 | while ((it != thread_tree.end()) && (count <= 0 || num_waiters < count) && | 97 | while ((it != thread_tree.end()) && (count <= 0 || num_waiters < count) && |
| 98 | (it->GetAddressArbiterKey() == addr)) { | 98 | (it->GetAddressArbiterKey() == addr)) { |
| 99 | Thread* target_thread = std::addressof(*it); | 99 | KThread* target_thread = std::addressof(*it); |
| 100 | target_thread->SetSyncedObject(nullptr, RESULT_SUCCESS); | 100 | target_thread->SetSyncedObject(nullptr, RESULT_SUCCESS); |
| 101 | 101 | ||
| 102 | ASSERT(target_thread->IsWaitingForAddressArbiter()); | 102 | ASSERT(target_thread->IsWaitingForAddressArbiter()); |
| @@ -125,7 +125,7 @@ ResultCode KAddressArbiter::SignalAndIncrementIfEqual(VAddr addr, s32 value, s32 | |||
| 125 | auto it = thread_tree.nfind_light({addr, -1}); | 125 | auto it = thread_tree.nfind_light({addr, -1}); |
| 126 | while ((it != thread_tree.end()) && (count <= 0 || num_waiters < count) && | 126 | while ((it != thread_tree.end()) && (count <= 0 || num_waiters < count) && |
| 127 | (it->GetAddressArbiterKey() == addr)) { | 127 | (it->GetAddressArbiterKey() == addr)) { |
| 128 | Thread* target_thread = std::addressof(*it); | 128 | KThread* target_thread = std::addressof(*it); |
| 129 | target_thread->SetSyncedObject(nullptr, RESULT_SUCCESS); | 129 | target_thread->SetSyncedObject(nullptr, RESULT_SUCCESS); |
| 130 | 130 | ||
| 131 | ASSERT(target_thread->IsWaitingForAddressArbiter()); | 131 | ASSERT(target_thread->IsWaitingForAddressArbiter()); |
| @@ -215,7 +215,7 @@ ResultCode KAddressArbiter::SignalAndModifyByWaitingCountIfEqual(VAddr addr, s32 | |||
| 215 | 215 | ||
| 216 | while ((it != thread_tree.end()) && (count <= 0 || num_waiters < count) && | 216 | while ((it != thread_tree.end()) && (count <= 0 || num_waiters < count) && |
| 217 | (it->GetAddressArbiterKey() == addr)) { | 217 | (it->GetAddressArbiterKey() == addr)) { |
| 218 | Thread* target_thread = std::addressof(*it); | 218 | KThread* target_thread = std::addressof(*it); |
| 219 | target_thread->SetSyncedObject(nullptr, RESULT_SUCCESS); | 219 | target_thread->SetSyncedObject(nullptr, RESULT_SUCCESS); |
| 220 | 220 | ||
| 221 | ASSERT(target_thread->IsWaitingForAddressArbiter()); | 221 | ASSERT(target_thread->IsWaitingForAddressArbiter()); |
| @@ -231,7 +231,7 @@ ResultCode KAddressArbiter::SignalAndModifyByWaitingCountIfEqual(VAddr addr, s32 | |||
| 231 | 231 | ||
| 232 | ResultCode KAddressArbiter::WaitIfLessThan(VAddr addr, s32 value, bool decrement, s64 timeout) { | 232 | ResultCode KAddressArbiter::WaitIfLessThan(VAddr addr, s32 value, bool decrement, s64 timeout) { |
| 233 | // Prepare to wait. | 233 | // Prepare to wait. |
| 234 | Thread* cur_thread = kernel.CurrentScheduler()->GetCurrentThread(); | 234 | KThread* cur_thread = kernel.CurrentScheduler()->GetCurrentThread(); |
| 235 | Handle timer = InvalidHandle; | 235 | Handle timer = InvalidHandle; |
| 236 | 236 | ||
| 237 | { | 237 | { |
| @@ -302,7 +302,7 @@ ResultCode KAddressArbiter::WaitIfLessThan(VAddr addr, s32 value, bool decrement | |||
| 302 | 302 | ||
| 303 | ResultCode KAddressArbiter::WaitIfEqual(VAddr addr, s32 value, s64 timeout) { | 303 | ResultCode KAddressArbiter::WaitIfEqual(VAddr addr, s32 value, s64 timeout) { |
| 304 | // Prepare to wait. | 304 | // Prepare to wait. |
| 305 | Thread* cur_thread = kernel.CurrentScheduler()->GetCurrentThread(); | 305 | KThread* cur_thread = kernel.CurrentScheduler()->GetCurrentThread(); |
| 306 | Handle timer = InvalidHandle; | 306 | Handle timer = InvalidHandle; |
| 307 | 307 | ||
| 308 | { | 308 | { |
diff --git a/src/core/hle/kernel/k_condition_variable.cpp b/src/core/hle/kernel/k_condition_variable.cpp index 49a068310..2fa2d5289 100644 --- a/src/core/hle/kernel/k_condition_variable.cpp +++ b/src/core/hle/kernel/k_condition_variable.cpp | |||
| @@ -10,11 +10,11 @@ | |||
| 10 | #include "core/hle/kernel/k_scheduler.h" | 10 | #include "core/hle/kernel/k_scheduler.h" |
| 11 | #include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h" | 11 | #include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h" |
| 12 | #include "core/hle/kernel/k_synchronization_object.h" | 12 | #include "core/hle/kernel/k_synchronization_object.h" |
| 13 | #include "core/hle/kernel/k_thread.h" | ||
| 13 | #include "core/hle/kernel/kernel.h" | 14 | #include "core/hle/kernel/kernel.h" |
| 14 | #include "core/hle/kernel/process.h" | 15 | #include "core/hle/kernel/process.h" |
| 15 | #include "core/hle/kernel/svc_common.h" | 16 | #include "core/hle/kernel/svc_common.h" |
| 16 | #include "core/hle/kernel/svc_results.h" | 17 | #include "core/hle/kernel/svc_results.h" |
| 17 | #include "core/hle/kernel/thread.h" | ||
| 18 | #include "core/memory.h" | 18 | #include "core/memory.h" |
| 19 | 19 | ||
| 20 | namespace Kernel { | 20 | namespace Kernel { |
| @@ -66,7 +66,7 @@ KConditionVariable::KConditionVariable(Core::System& system_) | |||
| 66 | KConditionVariable::~KConditionVariable() = default; | 66 | KConditionVariable::~KConditionVariable() = default; |
| 67 | 67 | ||
| 68 | ResultCode KConditionVariable::SignalToAddress(VAddr addr) { | 68 | ResultCode KConditionVariable::SignalToAddress(VAddr addr) { |
| 69 | Thread* owner_thread = kernel.CurrentScheduler()->GetCurrentThread(); | 69 | KThread* owner_thread = kernel.CurrentScheduler()->GetCurrentThread(); |
| 70 | 70 | ||
| 71 | // Signal the address. | 71 | // Signal the address. |
| 72 | { | 72 | { |
| @@ -74,7 +74,7 @@ ResultCode KConditionVariable::SignalToAddress(VAddr addr) { | |||
| 74 | 74 | ||
| 75 | // Remove waiter thread. | 75 | // Remove waiter thread. |
| 76 | s32 num_waiters{}; | 76 | s32 num_waiters{}; |
| 77 | Thread* next_owner_thread = | 77 | KThread* next_owner_thread = |
| 78 | owner_thread->RemoveWaiterByKey(std::addressof(num_waiters), addr); | 78 | owner_thread->RemoveWaiterByKey(std::addressof(num_waiters), addr); |
| 79 | 79 | ||
| 80 | // Determine the next tag. | 80 | // Determine the next tag. |
| @@ -103,11 +103,11 @@ ResultCode KConditionVariable::SignalToAddress(VAddr addr) { | |||
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | ResultCode KConditionVariable::WaitForAddress(Handle handle, VAddr addr, u32 value) { | 105 | ResultCode KConditionVariable::WaitForAddress(Handle handle, VAddr addr, u32 value) { |
| 106 | Thread* cur_thread = kernel.CurrentScheduler()->GetCurrentThread(); | 106 | KThread* cur_thread = kernel.CurrentScheduler()->GetCurrentThread(); |
| 107 | 107 | ||
| 108 | // Wait for the address. | 108 | // Wait for the address. |
| 109 | { | 109 | { |
| 110 | std::shared_ptr<Thread> owner_thread; | 110 | std::shared_ptr<KThread> owner_thread; |
| 111 | ASSERT(!owner_thread); | 111 | ASSERT(!owner_thread); |
| 112 | { | 112 | { |
| 113 | KScopedSchedulerLock sl(kernel); | 113 | KScopedSchedulerLock sl(kernel); |
| @@ -126,7 +126,7 @@ ResultCode KConditionVariable::WaitForAddress(Handle handle, VAddr addr, u32 val | |||
| 126 | R_UNLESS(test_tag == (handle | Svc::HandleWaitMask), RESULT_SUCCESS); | 126 | R_UNLESS(test_tag == (handle | Svc::HandleWaitMask), RESULT_SUCCESS); |
| 127 | 127 | ||
| 128 | // Get the lock owner thread. | 128 | // Get the lock owner thread. |
| 129 | owner_thread = kernel.CurrentProcess()->GetHandleTable().Get<Thread>(handle); | 129 | owner_thread = kernel.CurrentProcess()->GetHandleTable().Get<KThread>(handle); |
| 130 | R_UNLESS(owner_thread, Svc::ResultInvalidHandle); | 130 | R_UNLESS(owner_thread, Svc::ResultInvalidHandle); |
| 131 | 131 | ||
| 132 | // Update the lock. | 132 | // Update the lock. |
| @@ -143,7 +143,7 @@ ResultCode KConditionVariable::WaitForAddress(Handle handle, VAddr addr, u32 val | |||
| 143 | // Remove the thread as a waiter from the lock owner. | 143 | // Remove the thread as a waiter from the lock owner. |
| 144 | { | 144 | { |
| 145 | KScopedSchedulerLock sl(kernel); | 145 | KScopedSchedulerLock sl(kernel); |
| 146 | Thread* owner_thread = cur_thread->GetLockOwner(); | 146 | KThread* owner_thread = cur_thread->GetLockOwner(); |
| 147 | if (owner_thread != nullptr) { | 147 | if (owner_thread != nullptr) { |
| 148 | owner_thread->RemoveWaiter(cur_thread); | 148 | owner_thread->RemoveWaiter(cur_thread); |
| 149 | } | 149 | } |
| @@ -154,7 +154,7 @@ ResultCode KConditionVariable::WaitForAddress(Handle handle, VAddr addr, u32 val | |||
| 154 | return cur_thread->GetWaitResult(std::addressof(dummy)); | 154 | return cur_thread->GetWaitResult(std::addressof(dummy)); |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | Thread* KConditionVariable::SignalImpl(Thread* thread) { | 157 | KThread* KConditionVariable::SignalImpl(KThread* thread) { |
| 158 | // Check pre-conditions. | 158 | // Check pre-conditions. |
| 159 | ASSERT(kernel.GlobalSchedulerContext().IsLocked()); | 159 | ASSERT(kernel.GlobalSchedulerContext().IsLocked()); |
| 160 | 160 | ||
| @@ -174,7 +174,7 @@ Thread* KConditionVariable::SignalImpl(Thread* thread) { | |||
| 174 | } | 174 | } |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | Thread* thread_to_close = nullptr; | 177 | KThread* thread_to_close = nullptr; |
| 178 | if (can_access) { | 178 | if (can_access) { |
| 179 | if (prev_tag == InvalidHandle) { | 179 | if (prev_tag == InvalidHandle) { |
| 180 | // If nobody held the lock previously, we're all good. | 180 | // If nobody held the lock previously, we're all good. |
| @@ -182,7 +182,7 @@ Thread* KConditionVariable::SignalImpl(Thread* thread) { | |||
| 182 | thread->Wakeup(); | 182 | thread->Wakeup(); |
| 183 | } else { | 183 | } else { |
| 184 | // Get the previous owner. | 184 | // Get the previous owner. |
| 185 | auto owner_thread = kernel.CurrentProcess()->GetHandleTable().Get<Thread>( | 185 | auto owner_thread = kernel.CurrentProcess()->GetHandleTable().Get<KThread>( |
| 186 | prev_tag & ~Svc::HandleWaitMask); | 186 | prev_tag & ~Svc::HandleWaitMask); |
| 187 | 187 | ||
| 188 | if (owner_thread) { | 188 | if (owner_thread) { |
| @@ -210,8 +210,8 @@ void KConditionVariable::Signal(u64 cv_key, s32 count) { | |||
| 210 | 210 | ||
| 211 | // TODO(bunnei): This should just be Thread once we implement KAutoObject instead of using | 211 | // TODO(bunnei): This should just be Thread once we implement KAutoObject instead of using |
| 212 | // std::shared_ptr. | 212 | // std::shared_ptr. |
| 213 | std::vector<std::shared_ptr<Thread>> thread_list; | 213 | std::vector<std::shared_ptr<KThread>> thread_list; |
| 214 | std::array<Thread*, MaxThreads> thread_array; | 214 | std::array<KThread*, MaxThreads> thread_array; |
| 215 | s32 num_to_close{}; | 215 | s32 num_to_close{}; |
| 216 | 216 | ||
| 217 | // Perform signaling. | 217 | // Perform signaling. |
| @@ -222,9 +222,9 @@ void KConditionVariable::Signal(u64 cv_key, s32 count) { | |||
| 222 | auto it = thread_tree.nfind_light({cv_key, -1}); | 222 | auto it = thread_tree.nfind_light({cv_key, -1}); |
| 223 | while ((it != thread_tree.end()) && (count <= 0 || num_waiters < count) && | 223 | while ((it != thread_tree.end()) && (count <= 0 || num_waiters < count) && |
| 224 | (it->GetConditionVariableKey() == cv_key)) { | 224 | (it->GetConditionVariableKey() == cv_key)) { |
| 225 | Thread* target_thread = std::addressof(*it); | 225 | KThread* target_thread = std::addressof(*it); |
| 226 | 226 | ||
| 227 | if (Thread* thread = SignalImpl(target_thread); thread != nullptr) { | 227 | if (KThread* thread = SignalImpl(target_thread); thread != nullptr) { |
| 228 | if (num_to_close < MaxThreads) { | 228 | if (num_to_close < MaxThreads) { |
| 229 | thread_array[num_to_close++] = thread; | 229 | thread_array[num_to_close++] = thread; |
| 230 | } else { | 230 | } else { |
| @@ -257,7 +257,7 @@ void KConditionVariable::Signal(u64 cv_key, s32 count) { | |||
| 257 | 257 | ||
| 258 | ResultCode KConditionVariable::Wait(VAddr addr, u64 key, u32 value, s64 timeout) { | 258 | ResultCode KConditionVariable::Wait(VAddr addr, u64 key, u32 value, s64 timeout) { |
| 259 | // Prepare to wait. | 259 | // Prepare to wait. |
| 260 | Thread* cur_thread = kernel.CurrentScheduler()->GetCurrentThread(); | 260 | KThread* cur_thread = kernel.CurrentScheduler()->GetCurrentThread(); |
| 261 | Handle timer = InvalidHandle; | 261 | Handle timer = InvalidHandle; |
| 262 | 262 | ||
| 263 | { | 263 | { |
| @@ -276,7 +276,7 @@ ResultCode KConditionVariable::Wait(VAddr addr, u64 key, u32 value, s64 timeout) | |||
| 276 | { | 276 | { |
| 277 | // Remove waiter thread. | 277 | // Remove waiter thread. |
| 278 | s32 num_waiters{}; | 278 | s32 num_waiters{}; |
| 279 | Thread* next_owner_thread = | 279 | KThread* next_owner_thread = |
| 280 | cur_thread->RemoveWaiterByKey(std::addressof(num_waiters), addr); | 280 | cur_thread->RemoveWaiterByKey(std::addressof(num_waiters), addr); |
| 281 | 281 | ||
| 282 | // Update for the next owner thread. | 282 | // Update for the next owner thread. |
| @@ -331,7 +331,7 @@ ResultCode KConditionVariable::Wait(VAddr addr, u64 key, u32 value, s64 timeout) | |||
| 331 | { | 331 | { |
| 332 | KScopedSchedulerLock sl(kernel); | 332 | KScopedSchedulerLock sl(kernel); |
| 333 | 333 | ||
| 334 | if (Thread* owner = cur_thread->GetLockOwner(); owner != nullptr) { | 334 | if (KThread* owner = cur_thread->GetLockOwner(); owner != nullptr) { |
| 335 | owner->RemoveWaiter(cur_thread); | 335 | owner->RemoveWaiter(cur_thread); |
| 336 | } | 336 | } |
| 337 | 337 | ||
diff --git a/src/core/hle/kernel/k_condition_variable.h b/src/core/hle/kernel/k_condition_variable.h index 98ed5b323..861dbd420 100644 --- a/src/core/hle/kernel/k_condition_variable.h +++ b/src/core/hle/kernel/k_condition_variable.h | |||
| @@ -8,8 +8,8 @@ | |||
| 8 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 9 | 9 | ||
| 10 | #include "core/hle/kernel/k_scheduler.h" | 10 | #include "core/hle/kernel/k_scheduler.h" |
| 11 | #include "core/hle/kernel/k_thread.h" | ||
| 11 | #include "core/hle/kernel/kernel.h" | 12 | #include "core/hle/kernel/kernel.h" |
| 12 | #include "core/hle/kernel/thread.h" | ||
| 13 | #include "core/hle/result.h" | 13 | #include "core/hle/result.h" |
| 14 | 14 | ||
| 15 | namespace Core { | 15 | namespace Core { |
| @@ -20,7 +20,7 @@ namespace Kernel { | |||
| 20 | 20 | ||
| 21 | class KConditionVariable { | 21 | class KConditionVariable { |
| 22 | public: | 22 | public: |
| 23 | using ThreadTree = typename Thread::ConditionVariableThreadTreeType; | 23 | using ThreadTree = typename KThread::ConditionVariableThreadTreeType; |
| 24 | 24 | ||
| 25 | explicit KConditionVariable(Core::System& system_); | 25 | explicit KConditionVariable(Core::System& system_); |
| 26 | ~KConditionVariable(); | 26 | ~KConditionVariable(); |
| @@ -34,7 +34,7 @@ public: | |||
| 34 | [[nodiscard]] ResultCode Wait(VAddr addr, u64 key, u32 value, s64 timeout); | 34 | [[nodiscard]] ResultCode Wait(VAddr addr, u64 key, u32 value, s64 timeout); |
| 35 | 35 | ||
| 36 | private: | 36 | private: |
| 37 | [[nodiscard]] Thread* SignalImpl(Thread* thread); | 37 | [[nodiscard]] KThread* SignalImpl(KThread* thread); |
| 38 | 38 | ||
| 39 | ThreadTree thread_tree; | 39 | ThreadTree thread_tree; |
| 40 | 40 | ||
| @@ -43,14 +43,14 @@ private: | |||
| 43 | }; | 43 | }; |
| 44 | 44 | ||
| 45 | inline void BeforeUpdatePriority(const KernelCore& kernel, KConditionVariable::ThreadTree* tree, | 45 | inline void BeforeUpdatePriority(const KernelCore& kernel, KConditionVariable::ThreadTree* tree, |
| 46 | Thread* thread) { | 46 | KThread* thread) { |
| 47 | ASSERT(kernel.GlobalSchedulerContext().IsLocked()); | 47 | ASSERT(kernel.GlobalSchedulerContext().IsLocked()); |
| 48 | 48 | ||
| 49 | tree->erase(tree->iterator_to(*thread)); | 49 | tree->erase(tree->iterator_to(*thread)); |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | inline void AfterUpdatePriority(const KernelCore& kernel, KConditionVariable::ThreadTree* tree, | 52 | inline void AfterUpdatePriority(const KernelCore& kernel, KConditionVariable::ThreadTree* tree, |
| 53 | Thread* thread) { | 53 | KThread* thread) { |
| 54 | ASSERT(kernel.GlobalSchedulerContext().IsLocked()); | 54 | ASSERT(kernel.GlobalSchedulerContext().IsLocked()); |
| 55 | 55 | ||
| 56 | tree->insert(*thread); | 56 | tree->insert(*thread); |
diff --git a/src/core/hle/kernel/k_priority_queue.h b/src/core/hle/kernel/k_priority_queue.h index 0dc929040..13d628b85 100644 --- a/src/core/hle/kernel/k_priority_queue.h +++ b/src/core/hle/kernel/k_priority_queue.h | |||
| @@ -18,7 +18,7 @@ | |||
| 18 | 18 | ||
| 19 | namespace Kernel { | 19 | namespace Kernel { |
| 20 | 20 | ||
| 21 | class Thread; | 21 | class KThread; |
| 22 | 22 | ||
| 23 | template <typename T> | 23 | template <typename T> |
| 24 | concept KPriorityQueueAffinityMask = !std::is_reference_v<T> && requires(T & t) { | 24 | concept KPriorityQueueAffinityMask = !std::is_reference_v<T> && requires(T & t) { |
| @@ -367,7 +367,7 @@ public: | |||
| 367 | this->scheduled_queue.MoveToFront(member->GetPriority(), member->GetActiveCore(), member); | 367 | this->scheduled_queue.MoveToFront(member->GetPriority(), member->GetActiveCore(), member); |
| 368 | } | 368 | } |
| 369 | 369 | ||
| 370 | constexpr Thread* MoveToScheduledBack(Member* member) { | 370 | constexpr KThread* MoveToScheduledBack(Member* member) { |
| 371 | return this->scheduled_queue.MoveToBack(member->GetPriority(), member->GetActiveCore(), | 371 | return this->scheduled_queue.MoveToBack(member->GetPriority(), member->GetActiveCore(), |
| 372 | member); | 372 | member); |
| 373 | } | 373 | } |
diff --git a/src/core/hle/kernel/k_scheduler.cpp b/src/core/hle/kernel/k_scheduler.cpp index 12b5619fb..0f7a541c8 100644 --- a/src/core/hle/kernel/k_scheduler.cpp +++ b/src/core/hle/kernel/k_scheduler.cpp | |||
| @@ -17,15 +17,15 @@ | |||
| 17 | #include "core/cpu_manager.h" | 17 | #include "core/cpu_manager.h" |
| 18 | #include "core/hle/kernel/k_scheduler.h" | 18 | #include "core/hle/kernel/k_scheduler.h" |
| 19 | #include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h" | 19 | #include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h" |
| 20 | #include "core/hle/kernel/k_thread.h" | ||
| 20 | #include "core/hle/kernel/kernel.h" | 21 | #include "core/hle/kernel/kernel.h" |
| 21 | #include "core/hle/kernel/physical_core.h" | 22 | #include "core/hle/kernel/physical_core.h" |
| 22 | #include "core/hle/kernel/process.h" | 23 | #include "core/hle/kernel/process.h" |
| 23 | #include "core/hle/kernel/thread.h" | ||
| 24 | #include "core/hle/kernel/time_manager.h" | 24 | #include "core/hle/kernel/time_manager.h" |
| 25 | 25 | ||
| 26 | namespace Kernel { | 26 | namespace Kernel { |
| 27 | 27 | ||
| 28 | static void IncrementScheduledCount(Kernel::Thread* thread) { | 28 | static void IncrementScheduledCount(Kernel::KThread* thread) { |
| 29 | if (auto process = thread->GetOwnerProcess(); process) { | 29 | if (auto process = thread->GetOwnerProcess(); process) { |
| 30 | process->IncrementScheduledCount(); | 30 | process->IncrementScheduledCount(); |
| 31 | } | 31 | } |
| @@ -56,9 +56,9 @@ void KScheduler::RescheduleCores(KernelCore& kernel, u64 cores_pending_reschedul | |||
| 56 | } | 56 | } |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | u64 KScheduler::UpdateHighestPriorityThread(Thread* highest_thread) { | 59 | u64 KScheduler::UpdateHighestPriorityThread(KThread* highest_thread) { |
| 60 | std::scoped_lock lock{guard}; | 60 | std::scoped_lock lock{guard}; |
| 61 | if (Thread* prev_highest_thread = this->state.highest_priority_thread; | 61 | if (KThread* prev_highest_thread = this->state.highest_priority_thread; |
| 62 | prev_highest_thread != highest_thread) { | 62 | prev_highest_thread != highest_thread) { |
| 63 | if (prev_highest_thread != nullptr) { | 63 | if (prev_highest_thread != nullptr) { |
| 64 | IncrementScheduledCount(prev_highest_thread); | 64 | IncrementScheduledCount(prev_highest_thread); |
| @@ -90,13 +90,13 @@ u64 KScheduler::UpdateHighestPriorityThreadsImpl(KernelCore& kernel) { | |||
| 90 | ClearSchedulerUpdateNeeded(kernel); | 90 | ClearSchedulerUpdateNeeded(kernel); |
| 91 | 91 | ||
| 92 | u64 cores_needing_scheduling = 0, idle_cores = 0; | 92 | u64 cores_needing_scheduling = 0, idle_cores = 0; |
| 93 | Thread* top_threads[Core::Hardware::NUM_CPU_CORES]; | 93 | KThread* top_threads[Core::Hardware::NUM_CPU_CORES]; |
| 94 | auto& priority_queue = GetPriorityQueue(kernel); | 94 | auto& priority_queue = GetPriorityQueue(kernel); |
| 95 | 95 | ||
| 96 | /// We want to go over all cores, finding the highest priority thread and determining if | 96 | /// We want to go over all cores, finding the highest priority thread and determining if |
| 97 | /// scheduling is needed for that core. | 97 | /// scheduling is needed for that core. |
| 98 | for (size_t core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) { | 98 | for (size_t core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) { |
| 99 | Thread* top_thread = priority_queue.GetScheduledFront(static_cast<s32>(core_id)); | 99 | KThread* top_thread = priority_queue.GetScheduledFront(static_cast<s32>(core_id)); |
| 100 | if (top_thread != nullptr) { | 100 | if (top_thread != nullptr) { |
| 101 | // If the thread has no waiters, we need to check if the process has a thread pinned. | 101 | // If the thread has no waiters, we need to check if the process has a thread pinned. |
| 102 | // TODO(bunnei): Implement thread pinning | 102 | // TODO(bunnei): Implement thread pinning |
| @@ -112,7 +112,7 @@ u64 KScheduler::UpdateHighestPriorityThreadsImpl(KernelCore& kernel) { | |||
| 112 | // Idle cores are bad. We're going to try to migrate threads to each idle core in turn. | 112 | // Idle cores are bad. We're going to try to migrate threads to each idle core in turn. |
| 113 | while (idle_cores != 0) { | 113 | while (idle_cores != 0) { |
| 114 | const auto core_id = static_cast<u32>(std::countr_zero(idle_cores)); | 114 | const auto core_id = static_cast<u32>(std::countr_zero(idle_cores)); |
| 115 | if (Thread* suggested = priority_queue.GetSuggestedFront(core_id); suggested != nullptr) { | 115 | if (KThread* suggested = priority_queue.GetSuggestedFront(core_id); suggested != nullptr) { |
| 116 | s32 migration_candidates[Core::Hardware::NUM_CPU_CORES]; | 116 | s32 migration_candidates[Core::Hardware::NUM_CPU_CORES]; |
| 117 | size_t num_candidates = 0; | 117 | size_t num_candidates = 0; |
| 118 | 118 | ||
| @@ -120,7 +120,7 @@ u64 KScheduler::UpdateHighestPriorityThreadsImpl(KernelCore& kernel) { | |||
| 120 | while (suggested != nullptr) { | 120 | while (suggested != nullptr) { |
| 121 | // Check if the suggested thread is the top thread on its core. | 121 | // Check if the suggested thread is the top thread on its core. |
| 122 | const s32 suggested_core = suggested->GetActiveCore(); | 122 | const s32 suggested_core = suggested->GetActiveCore(); |
| 123 | if (Thread* top_thread = | 123 | if (KThread* top_thread = |
| 124 | (suggested_core >= 0) ? top_threads[suggested_core] : nullptr; | 124 | (suggested_core >= 0) ? top_threads[suggested_core] : nullptr; |
| 125 | top_thread != suggested) { | 125 | top_thread != suggested) { |
| 126 | // Make sure we're not dealing with threads too high priority for migration. | 126 | // Make sure we're not dealing with threads too high priority for migration. |
| @@ -152,7 +152,7 @@ u64 KScheduler::UpdateHighestPriorityThreadsImpl(KernelCore& kernel) { | |||
| 152 | // Check if there's some other thread that can run on the candidate core. | 152 | // Check if there's some other thread that can run on the candidate core. |
| 153 | const s32 candidate_core = migration_candidates[i]; | 153 | const s32 candidate_core = migration_candidates[i]; |
| 154 | suggested = top_threads[candidate_core]; | 154 | suggested = top_threads[candidate_core]; |
| 155 | if (Thread* next_on_candidate_core = | 155 | if (KThread* next_on_candidate_core = |
| 156 | priority_queue.GetScheduledNext(candidate_core, suggested); | 156 | priority_queue.GetScheduledNext(candidate_core, suggested); |
| 157 | next_on_candidate_core != nullptr) { | 157 | next_on_candidate_core != nullptr) { |
| 158 | // The candidate core can run some other thread! We'll migrate its current | 158 | // The candidate core can run some other thread! We'll migrate its current |
| @@ -182,7 +182,7 @@ u64 KScheduler::UpdateHighestPriorityThreadsImpl(KernelCore& kernel) { | |||
| 182 | return cores_needing_scheduling; | 182 | return cores_needing_scheduling; |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | void KScheduler::OnThreadStateChanged(KernelCore& kernel, Thread* thread, ThreadState old_state) { | 185 | void KScheduler::OnThreadStateChanged(KernelCore& kernel, KThread* thread, ThreadState old_state) { |
| 186 | ASSERT(kernel.GlobalSchedulerContext().IsLocked()); | 186 | ASSERT(kernel.GlobalSchedulerContext().IsLocked()); |
| 187 | 187 | ||
| 188 | // Check if the state has changed, because if it hasn't there's nothing to do. | 188 | // Check if the state has changed, because if it hasn't there's nothing to do. |
| @@ -205,7 +205,7 @@ void KScheduler::OnThreadStateChanged(KernelCore& kernel, Thread* thread, Thread | |||
| 205 | } | 205 | } |
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | void KScheduler::OnThreadPriorityChanged(KernelCore& kernel, Thread* thread, s32 old_priority) { | 208 | void KScheduler::OnThreadPriorityChanged(KernelCore& kernel, KThread* thread, s32 old_priority) { |
| 209 | ASSERT(kernel.GlobalSchedulerContext().IsLocked()); | 209 | ASSERT(kernel.GlobalSchedulerContext().IsLocked()); |
| 210 | 210 | ||
| 211 | // If the thread is runnable, we want to change its priority in the queue. | 211 | // If the thread is runnable, we want to change its priority in the queue. |
| @@ -217,7 +217,7 @@ void KScheduler::OnThreadPriorityChanged(KernelCore& kernel, Thread* thread, s32 | |||
| 217 | } | 217 | } |
| 218 | } | 218 | } |
| 219 | 219 | ||
| 220 | void KScheduler::OnThreadAffinityMaskChanged(KernelCore& kernel, Thread* thread, | 220 | void KScheduler::OnThreadAffinityMaskChanged(KernelCore& kernel, KThread* thread, |
| 221 | const KAffinityMask& old_affinity, s32 old_core) { | 221 | const KAffinityMask& old_affinity, s32 old_core) { |
| 222 | ASSERT(kernel.GlobalSchedulerContext().IsLocked()); | 222 | ASSERT(kernel.GlobalSchedulerContext().IsLocked()); |
| 223 | 223 | ||
| @@ -237,8 +237,8 @@ void KScheduler::RotateScheduledQueue(s32 core_id, s32 priority) { | |||
| 237 | auto& priority_queue = GetPriorityQueue(kernel); | 237 | auto& priority_queue = GetPriorityQueue(kernel); |
| 238 | 238 | ||
| 239 | // Rotate the front of the queue to the end. | 239 | // Rotate the front of the queue to the end. |
| 240 | Thread* top_thread = priority_queue.GetScheduledFront(core_id, priority); | 240 | KThread* top_thread = priority_queue.GetScheduledFront(core_id, priority); |
| 241 | Thread* next_thread = nullptr; | 241 | KThread* next_thread = nullptr; |
| 242 | if (top_thread != nullptr) { | 242 | if (top_thread != nullptr) { |
| 243 | next_thread = priority_queue.MoveToScheduledBack(top_thread); | 243 | next_thread = priority_queue.MoveToScheduledBack(top_thread); |
| 244 | if (next_thread != top_thread) { | 244 | if (next_thread != top_thread) { |
| @@ -249,11 +249,11 @@ void KScheduler::RotateScheduledQueue(s32 core_id, s32 priority) { | |||
| 249 | 249 | ||
| 250 | // While we have a suggested thread, try to migrate it! | 250 | // While we have a suggested thread, try to migrate it! |
| 251 | { | 251 | { |
| 252 | Thread* suggested = priority_queue.GetSuggestedFront(core_id, priority); | 252 | KThread* suggested = priority_queue.GetSuggestedFront(core_id, priority); |
| 253 | while (suggested != nullptr) { | 253 | while (suggested != nullptr) { |
| 254 | // Check if the suggested thread is the top thread on its core. | 254 | // Check if the suggested thread is the top thread on its core. |
| 255 | const s32 suggested_core = suggested->GetActiveCore(); | 255 | const s32 suggested_core = suggested->GetActiveCore(); |
| 256 | if (Thread* top_on_suggested_core = | 256 | if (KThread* top_on_suggested_core = |
| 257 | (suggested_core >= 0) ? priority_queue.GetScheduledFront(suggested_core) | 257 | (suggested_core >= 0) ? priority_queue.GetScheduledFront(suggested_core) |
| 258 | : nullptr; | 258 | : nullptr; |
| 259 | top_on_suggested_core != suggested) { | 259 | top_on_suggested_core != suggested) { |
| @@ -285,7 +285,7 @@ void KScheduler::RotateScheduledQueue(s32 core_id, s32 priority) { | |||
| 285 | // Now that we might have migrated a thread with the same priority, check if we can do better. | 285 | // Now that we might have migrated a thread with the same priority, check if we can do better. |
| 286 | 286 | ||
| 287 | { | 287 | { |
| 288 | Thread* best_thread = priority_queue.GetScheduledFront(core_id); | 288 | KThread* best_thread = priority_queue.GetScheduledFront(core_id); |
| 289 | if (best_thread == GetCurrentThread()) { | 289 | if (best_thread == GetCurrentThread()) { |
| 290 | best_thread = priority_queue.GetScheduledNext(core_id, best_thread); | 290 | best_thread = priority_queue.GetScheduledNext(core_id, best_thread); |
| 291 | } | 291 | } |
| @@ -293,7 +293,7 @@ void KScheduler::RotateScheduledQueue(s32 core_id, s32 priority) { | |||
| 293 | // If the best thread we can choose has a priority the same or worse than ours, try to | 293 | // If the best thread we can choose has a priority the same or worse than ours, try to |
| 294 | // migrate a higher priority thread. | 294 | // migrate a higher priority thread. |
| 295 | if (best_thread != nullptr && best_thread->GetPriority() >= priority) { | 295 | if (best_thread != nullptr && best_thread->GetPriority() >= priority) { |
| 296 | Thread* suggested = priority_queue.GetSuggestedFront(core_id); | 296 | KThread* suggested = priority_queue.GetSuggestedFront(core_id); |
| 297 | while (suggested != nullptr) { | 297 | while (suggested != nullptr) { |
| 298 | // If the suggestion's priority is the same as ours, don't bother. | 298 | // If the suggestion's priority is the same as ours, don't bother. |
| 299 | if (suggested->GetPriority() >= best_thread->GetPriority()) { | 299 | if (suggested->GetPriority() >= best_thread->GetPriority()) { |
| @@ -302,7 +302,7 @@ void KScheduler::RotateScheduledQueue(s32 core_id, s32 priority) { | |||
| 302 | 302 | ||
| 303 | // Check if the suggested thread is the top thread on its core. | 303 | // Check if the suggested thread is the top thread on its core. |
| 304 | const s32 suggested_core = suggested->GetActiveCore(); | 304 | const s32 suggested_core = suggested->GetActiveCore(); |
| 305 | if (Thread* top_on_suggested_core = | 305 | if (KThread* top_on_suggested_core = |
| 306 | (suggested_core >= 0) ? priority_queue.GetScheduledFront(suggested_core) | 306 | (suggested_core >= 0) ? priority_queue.GetScheduledFront(suggested_core) |
| 307 | : nullptr; | 307 | : nullptr; |
| 308 | top_on_suggested_core != suggested) { | 308 | top_on_suggested_core != suggested) { |
| @@ -380,7 +380,7 @@ void KScheduler::YieldWithoutCoreMigration() { | |||
| 380 | ASSERT(kernel.CurrentProcess() != nullptr); | 380 | ASSERT(kernel.CurrentProcess() != nullptr); |
| 381 | 381 | ||
| 382 | // Get the current thread and process. | 382 | // Get the current thread and process. |
| 383 | Thread& cur_thread = *GetCurrentThread(); | 383 | KThread& cur_thread = *GetCurrentThread(); |
| 384 | Process& cur_process = *kernel.CurrentProcess(); | 384 | Process& cur_process = *kernel.CurrentProcess(); |
| 385 | 385 | ||
| 386 | // If the thread's yield count matches, there's nothing for us to do. | 386 | // If the thread's yield count matches, there's nothing for us to do. |
| @@ -398,7 +398,7 @@ void KScheduler::YieldWithoutCoreMigration() { | |||
| 398 | const auto cur_state = cur_thread.GetRawState(); | 398 | const auto cur_state = cur_thread.GetRawState(); |
| 399 | if (cur_state == ThreadState::Runnable) { | 399 | if (cur_state == ThreadState::Runnable) { |
| 400 | // Put the current thread at the back of the queue. | 400 | // Put the current thread at the back of the queue. |
| 401 | Thread* next_thread = priority_queue.MoveToScheduledBack(std::addressof(cur_thread)); | 401 | KThread* next_thread = priority_queue.MoveToScheduledBack(std::addressof(cur_thread)); |
| 402 | IncrementScheduledCount(std::addressof(cur_thread)); | 402 | IncrementScheduledCount(std::addressof(cur_thread)); |
| 403 | 403 | ||
| 404 | // If the next thread is different, we have an update to perform. | 404 | // If the next thread is different, we have an update to perform. |
| @@ -421,7 +421,7 @@ void KScheduler::YieldWithCoreMigration() { | |||
| 421 | ASSERT(kernel.CurrentProcess() != nullptr); | 421 | ASSERT(kernel.CurrentProcess() != nullptr); |
| 422 | 422 | ||
| 423 | // Get the current thread and process. | 423 | // Get the current thread and process. |
| 424 | Thread& cur_thread = *GetCurrentThread(); | 424 | KThread& cur_thread = *GetCurrentThread(); |
| 425 | Process& cur_process = *kernel.CurrentProcess(); | 425 | Process& cur_process = *kernel.CurrentProcess(); |
| 426 | 426 | ||
| 427 | // If the thread's yield count matches, there's nothing for us to do. | 427 | // If the thread's yield count matches, there's nothing for us to do. |
| @@ -442,17 +442,17 @@ void KScheduler::YieldWithCoreMigration() { | |||
| 442 | const s32 core_id = cur_thread.GetActiveCore(); | 442 | const s32 core_id = cur_thread.GetActiveCore(); |
| 443 | 443 | ||
| 444 | // Put the current thread at the back of the queue. | 444 | // Put the current thread at the back of the queue. |
| 445 | Thread* next_thread = priority_queue.MoveToScheduledBack(std::addressof(cur_thread)); | 445 | KThread* next_thread = priority_queue.MoveToScheduledBack(std::addressof(cur_thread)); |
| 446 | IncrementScheduledCount(std::addressof(cur_thread)); | 446 | IncrementScheduledCount(std::addressof(cur_thread)); |
| 447 | 447 | ||
| 448 | // While we have a suggested thread, try to migrate it! | 448 | // While we have a suggested thread, try to migrate it! |
| 449 | bool recheck = false; | 449 | bool recheck = false; |
| 450 | Thread* suggested = priority_queue.GetSuggestedFront(core_id); | 450 | KThread* suggested = priority_queue.GetSuggestedFront(core_id); |
| 451 | while (suggested != nullptr) { | 451 | while (suggested != nullptr) { |
| 452 | // Check if the suggested thread is the thread running on its core. | 452 | // Check if the suggested thread is the thread running on its core. |
| 453 | const s32 suggested_core = suggested->GetActiveCore(); | 453 | const s32 suggested_core = suggested->GetActiveCore(); |
| 454 | 454 | ||
| 455 | if (Thread* running_on_suggested_core = | 455 | if (KThread* running_on_suggested_core = |
| 456 | (suggested_core >= 0) | 456 | (suggested_core >= 0) |
| 457 | ? kernel.Scheduler(suggested_core).state.highest_priority_thread | 457 | ? kernel.Scheduler(suggested_core).state.highest_priority_thread |
| 458 | : nullptr; | 458 | : nullptr; |
| @@ -511,7 +511,7 @@ void KScheduler::YieldToAnyThread() { | |||
| 511 | ASSERT(kernel.CurrentProcess() != nullptr); | 511 | ASSERT(kernel.CurrentProcess() != nullptr); |
| 512 | 512 | ||
| 513 | // Get the current thread and process. | 513 | // Get the current thread and process. |
| 514 | Thread& cur_thread = *GetCurrentThread(); | 514 | KThread& cur_thread = *GetCurrentThread(); |
| 515 | Process& cur_process = *kernel.CurrentProcess(); | 515 | Process& cur_process = *kernel.CurrentProcess(); |
| 516 | 516 | ||
| 517 | // If the thread's yield count matches, there's nothing for us to do. | 517 | // If the thread's yield count matches, there's nothing for us to do. |
| @@ -539,11 +539,11 @@ void KScheduler::YieldToAnyThread() { | |||
| 539 | // If there's nothing scheduled, we can try to perform a migration. | 539 | // If there's nothing scheduled, we can try to perform a migration. |
| 540 | if (priority_queue.GetScheduledFront(core_id) == nullptr) { | 540 | if (priority_queue.GetScheduledFront(core_id) == nullptr) { |
| 541 | // While we have a suggested thread, try to migrate it! | 541 | // While we have a suggested thread, try to migrate it! |
| 542 | Thread* suggested = priority_queue.GetSuggestedFront(core_id); | 542 | KThread* suggested = priority_queue.GetSuggestedFront(core_id); |
| 543 | while (suggested != nullptr) { | 543 | while (suggested != nullptr) { |
| 544 | // Check if the suggested thread is the top thread on its core. | 544 | // Check if the suggested thread is the top thread on its core. |
| 545 | const s32 suggested_core = suggested->GetActiveCore(); | 545 | const s32 suggested_core = suggested->GetActiveCore(); |
| 546 | if (Thread* top_on_suggested_core = | 546 | if (KThread* top_on_suggested_core = |
| 547 | (suggested_core >= 0) ? priority_queue.GetScheduledFront(suggested_core) | 547 | (suggested_core >= 0) ? priority_queue.GetScheduledFront(suggested_core) |
| 548 | : nullptr; | 548 | : nullptr; |
| 549 | top_on_suggested_core != suggested) { | 549 | top_on_suggested_core != suggested) { |
| @@ -594,7 +594,7 @@ KScheduler::KScheduler(Core::System& system, std::size_t core_id) | |||
| 594 | 594 | ||
| 595 | KScheduler::~KScheduler() = default; | 595 | KScheduler::~KScheduler() = default; |
| 596 | 596 | ||
| 597 | Thread* KScheduler::GetCurrentThread() const { | 597 | KThread* KScheduler::GetCurrentThread() const { |
| 598 | if (current_thread) { | 598 | if (current_thread) { |
| 599 | return current_thread; | 599 | return current_thread; |
| 600 | } | 600 | } |
| @@ -624,7 +624,7 @@ void KScheduler::OnThreadStart() { | |||
| 624 | SwitchContextStep2(); | 624 | SwitchContextStep2(); |
| 625 | } | 625 | } |
| 626 | 626 | ||
| 627 | void KScheduler::Unload(Thread* thread) { | 627 | void KScheduler::Unload(KThread* thread) { |
| 628 | if (thread) { | 628 | if (thread) { |
| 629 | thread->SetIsRunning(false); | 629 | thread->SetIsRunning(false); |
| 630 | if (thread->IsContinuousOnSVC() && !thread->IsHLEThread()) { | 630 | if (thread->IsContinuousOnSVC() && !thread->IsHLEThread()) { |
| @@ -643,7 +643,7 @@ void KScheduler::Unload(Thread* thread) { | |||
| 643 | } | 643 | } |
| 644 | } | 644 | } |
| 645 | 645 | ||
| 646 | void KScheduler::Reload(Thread* thread) { | 646 | void KScheduler::Reload(KThread* thread) { |
| 647 | if (thread) { | 647 | if (thread) { |
| 648 | ASSERT_MSG(thread->GetState() == ThreadState::Runnable, "Thread must be runnable."); | 648 | ASSERT_MSG(thread->GetState() == ThreadState::Runnable, "Thread must be runnable."); |
| 649 | 649 | ||
| @@ -674,7 +674,7 @@ void KScheduler::SwitchContextStep2() { | |||
| 674 | } | 674 | } |
| 675 | 675 | ||
| 676 | void KScheduler::ScheduleImpl() { | 676 | void KScheduler::ScheduleImpl() { |
| 677 | Thread* previous_thread = current_thread; | 677 | KThread* previous_thread = current_thread; |
| 678 | current_thread = state.highest_priority_thread; | 678 | current_thread = state.highest_priority_thread; |
| 679 | 679 | ||
| 680 | this->state.needs_scheduling = false; | 680 | this->state.needs_scheduling = false; |
| @@ -744,7 +744,7 @@ void KScheduler::SwitchToCurrent() { | |||
| 744 | } | 744 | } |
| 745 | } | 745 | } |
| 746 | 746 | ||
| 747 | void KScheduler::UpdateLastContextSwitchTime(Thread* thread, Process* process) { | 747 | void KScheduler::UpdateLastContextSwitchTime(KThread* thread, Process* process) { |
| 748 | const u64 prev_switch_ticks = last_context_switch_time; | 748 | const u64 prev_switch_ticks = last_context_switch_time; |
| 749 | const u64 most_recent_switch_ticks = system.CoreTiming().GetCPUTicks(); | 749 | const u64 most_recent_switch_ticks = system.CoreTiming().GetCPUTicks(); |
| 750 | const u64 update_ticks = most_recent_switch_ticks - prev_switch_ticks; | 750 | const u64 update_ticks = most_recent_switch_ticks - prev_switch_ticks; |
| @@ -765,8 +765,8 @@ void KScheduler::Initialize() { | |||
| 765 | std::function<void(void*)> init_func = Core::CpuManager::GetIdleThreadStartFunc(); | 765 | std::function<void(void*)> init_func = Core::CpuManager::GetIdleThreadStartFunc(); |
| 766 | void* init_func_parameter = system.GetCpuManager().GetStartFuncParamater(); | 766 | void* init_func_parameter = system.GetCpuManager().GetStartFuncParamater(); |
| 767 | ThreadType type = static_cast<ThreadType>(THREADTYPE_KERNEL | THREADTYPE_HLE | THREADTYPE_IDLE); | 767 | ThreadType type = static_cast<ThreadType>(THREADTYPE_KERNEL | THREADTYPE_HLE | THREADTYPE_IDLE); |
| 768 | auto thread_res = Thread::Create(system, type, name, 0, 64, 0, static_cast<u32>(core_id), 0, | 768 | auto thread_res = KThread::Create(system, type, name, 0, 64, 0, static_cast<u32>(core_id), 0, |
| 769 | nullptr, std::move(init_func), init_func_parameter); | 769 | nullptr, std::move(init_func), init_func_parameter); |
| 770 | idle_thread = thread_res.Unwrap().get(); | 770 | idle_thread = thread_res.Unwrap().get(); |
| 771 | 771 | ||
| 772 | { | 772 | { |
diff --git a/src/core/hle/kernel/k_scheduler.h b/src/core/hle/kernel/k_scheduler.h index 783665123..157373934 100644 --- a/src/core/hle/kernel/k_scheduler.h +++ b/src/core/hle/kernel/k_scheduler.h | |||
| @@ -29,7 +29,7 @@ namespace Kernel { | |||
| 29 | class KernelCore; | 29 | class KernelCore; |
| 30 | class Process; | 30 | class Process; |
| 31 | class SchedulerLock; | 31 | class SchedulerLock; |
| 32 | class Thread; | 32 | class KThread; |
| 33 | 33 | ||
| 34 | class KScheduler final { | 34 | class KScheduler final { |
| 35 | public: | 35 | public: |
| @@ -45,13 +45,13 @@ public: | |||
| 45 | 45 | ||
| 46 | /// The next two are for SingleCore Only. | 46 | /// The next two are for SingleCore Only. |
| 47 | /// Unload current thread before preempting core. | 47 | /// Unload current thread before preempting core. |
| 48 | void Unload(Thread* thread); | 48 | void Unload(KThread* thread); |
| 49 | 49 | ||
| 50 | /// Reload current thread after core preemption. | 50 | /// Reload current thread after core preemption. |
| 51 | void Reload(Thread* thread); | 51 | void Reload(KThread* thread); |
| 52 | 52 | ||
| 53 | /// Gets the current running thread | 53 | /// Gets the current running thread |
| 54 | [[nodiscard]] Thread* GetCurrentThread() const; | 54 | [[nodiscard]] KThread* GetCurrentThread() const; |
| 55 | 55 | ||
| 56 | /// Gets the timestamp for the last context switch in ticks. | 56 | /// Gets the timestamp for the last context switch in ticks. |
| 57 | [[nodiscard]] u64 GetLastContextSwitchTicks() const; | 57 | [[nodiscard]] u64 GetLastContextSwitchTicks() const; |
| @@ -72,7 +72,7 @@ public: | |||
| 72 | return switch_fiber; | 72 | return switch_fiber; |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | [[nodiscard]] u64 UpdateHighestPriorityThread(Thread* highest_thread); | 75 | [[nodiscard]] u64 UpdateHighestPriorityThread(KThread* highest_thread); |
| 76 | 76 | ||
| 77 | /** | 77 | /** |
| 78 | * Takes a thread and moves it to the back of the it's priority list. | 78 | * Takes a thread and moves it to the back of the it's priority list. |
| @@ -100,13 +100,13 @@ public: | |||
| 100 | void YieldToAnyThread(); | 100 | void YieldToAnyThread(); |
| 101 | 101 | ||
| 102 | /// Notify the scheduler a thread's status has changed. | 102 | /// Notify the scheduler a thread's status has changed. |
| 103 | static void OnThreadStateChanged(KernelCore& kernel, Thread* thread, ThreadState old_state); | 103 | static void OnThreadStateChanged(KernelCore& kernel, KThread* thread, ThreadState old_state); |
| 104 | 104 | ||
| 105 | /// Notify the scheduler a thread's priority has changed. | 105 | /// Notify the scheduler a thread's priority has changed. |
| 106 | static void OnThreadPriorityChanged(KernelCore& kernel, Thread* thread, s32 old_priority); | 106 | static void OnThreadPriorityChanged(KernelCore& kernel, KThread* thread, s32 old_priority); |
| 107 | 107 | ||
| 108 | /// Notify the scheduler a thread's core and/or affinity mask has changed. | 108 | /// Notify the scheduler a thread's core and/or affinity mask has changed. |
| 109 | static void OnThreadAffinityMaskChanged(KernelCore& kernel, Thread* thread, | 109 | static void OnThreadAffinityMaskChanged(KernelCore& kernel, KThread* thread, |
| 110 | const KAffinityMask& old_affinity, s32 old_core); | 110 | const KAffinityMask& old_affinity, s32 old_core); |
| 111 | 111 | ||
| 112 | static bool CanSchedule(KernelCore& kernel); | 112 | static bool CanSchedule(KernelCore& kernel); |
| @@ -163,13 +163,13 @@ private: | |||
| 163 | * most recent tick count retrieved. No special arithmetic is | 163 | * most recent tick count retrieved. No special arithmetic is |
| 164 | * applied to it. | 164 | * applied to it. |
| 165 | */ | 165 | */ |
| 166 | void UpdateLastContextSwitchTime(Thread* thread, Process* process); | 166 | void UpdateLastContextSwitchTime(KThread* thread, Process* process); |
| 167 | 167 | ||
| 168 | static void OnSwitch(void* this_scheduler); | 168 | static void OnSwitch(void* this_scheduler); |
| 169 | void SwitchToCurrent(); | 169 | void SwitchToCurrent(); |
| 170 | 170 | ||
| 171 | Thread* current_thread{}; | 171 | KThread* current_thread{}; |
| 172 | Thread* idle_thread{}; | 172 | KThread* idle_thread{}; |
| 173 | 173 | ||
| 174 | std::shared_ptr<Common::Fiber> switch_fiber{}; | 174 | std::shared_ptr<Common::Fiber> switch_fiber{}; |
| 175 | 175 | ||
| @@ -178,7 +178,7 @@ private: | |||
| 178 | bool interrupt_task_thread_runnable{}; | 178 | bool interrupt_task_thread_runnable{}; |
| 179 | bool should_count_idle{}; | 179 | bool should_count_idle{}; |
| 180 | u64 idle_count{}; | 180 | u64 idle_count{}; |
| 181 | Thread* highest_priority_thread{}; | 181 | KThread* highest_priority_thread{}; |
| 182 | void* idle_thread_stack{}; | 182 | void* idle_thread_stack{}; |
| 183 | }; | 183 | }; |
| 184 | 184 | ||
diff --git a/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h b/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h index 2bb3817fa..fac39aeb7 100644 --- a/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h +++ b/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h | |||
| @@ -9,15 +9,15 @@ | |||
| 9 | 9 | ||
| 10 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 11 | #include "core/hle/kernel/handle_table.h" | 11 | #include "core/hle/kernel/handle_table.h" |
| 12 | #include "core/hle/kernel/k_thread.h" | ||
| 12 | #include "core/hle/kernel/kernel.h" | 13 | #include "core/hle/kernel/kernel.h" |
| 13 | #include "core/hle/kernel/thread.h" | ||
| 14 | #include "core/hle/kernel/time_manager.h" | 14 | #include "core/hle/kernel/time_manager.h" |
| 15 | 15 | ||
| 16 | namespace Kernel { | 16 | namespace Kernel { |
| 17 | 17 | ||
| 18 | class KScopedSchedulerLockAndSleep { | 18 | class KScopedSchedulerLockAndSleep { |
| 19 | public: | 19 | public: |
| 20 | explicit KScopedSchedulerLockAndSleep(KernelCore& kernel, Handle& event_handle, Thread* t, | 20 | explicit KScopedSchedulerLockAndSleep(KernelCore& kernel, Handle& event_handle, KThread* t, |
| 21 | s64 timeout) | 21 | s64 timeout) |
| 22 | : kernel(kernel), event_handle(event_handle), thread(t), timeout_tick(timeout) { | 22 | : kernel(kernel), event_handle(event_handle), thread(t), timeout_tick(timeout) { |
| 23 | event_handle = InvalidHandle; | 23 | event_handle = InvalidHandle; |
| @@ -43,7 +43,7 @@ public: | |||
| 43 | private: | 43 | private: |
| 44 | KernelCore& kernel; | 44 | KernelCore& kernel; |
| 45 | Handle& event_handle; | 45 | Handle& event_handle; |
| 46 | Thread* thread{}; | 46 | KThread* thread{}; |
| 47 | s64 timeout_tick{}; | 47 | s64 timeout_tick{}; |
| 48 | }; | 48 | }; |
| 49 | 49 | ||
diff --git a/src/core/hle/kernel/k_synchronization_object.cpp b/src/core/hle/kernel/k_synchronization_object.cpp index 1c508cb55..61432fef8 100644 --- a/src/core/hle/kernel/k_synchronization_object.cpp +++ b/src/core/hle/kernel/k_synchronization_object.cpp | |||
| @@ -7,9 +7,9 @@ | |||
| 7 | #include "core/hle/kernel/k_scheduler.h" | 7 | #include "core/hle/kernel/k_scheduler.h" |
| 8 | #include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h" | 8 | #include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h" |
| 9 | #include "core/hle/kernel/k_synchronization_object.h" | 9 | #include "core/hle/kernel/k_synchronization_object.h" |
| 10 | #include "core/hle/kernel/k_thread.h" | ||
| 10 | #include "core/hle/kernel/kernel.h" | 11 | #include "core/hle/kernel/kernel.h" |
| 11 | #include "core/hle/kernel/svc_results.h" | 12 | #include "core/hle/kernel/svc_results.h" |
| 12 | #include "core/hle/kernel/thread.h" | ||
| 13 | 13 | ||
| 14 | namespace Kernel { | 14 | namespace Kernel { |
| 15 | 15 | ||
| @@ -20,7 +20,7 @@ ResultCode KSynchronizationObject::Wait(KernelCore& kernel, s32* out_index, | |||
| 20 | std::vector<ThreadListNode> thread_nodes(num_objects); | 20 | std::vector<ThreadListNode> thread_nodes(num_objects); |
| 21 | 21 | ||
| 22 | // Prepare for wait. | 22 | // Prepare for wait. |
| 23 | Thread* thread = kernel.CurrentScheduler()->GetCurrentThread(); | 23 | KThread* thread = kernel.CurrentScheduler()->GetCurrentThread(); |
| 24 | Handle timer = InvalidHandle; | 24 | Handle timer = InvalidHandle; |
| 25 | 25 | ||
| 26 | { | 26 | { |
| @@ -148,7 +148,7 @@ void KSynchronizationObject::NotifyAvailable(ResultCode result) { | |||
| 148 | 148 | ||
| 149 | // Iterate over each thread. | 149 | // Iterate over each thread. |
| 150 | for (auto* cur_node = thread_list_head; cur_node != nullptr; cur_node = cur_node->next) { | 150 | for (auto* cur_node = thread_list_head; cur_node != nullptr; cur_node = cur_node->next) { |
| 151 | Thread* thread = cur_node->thread; | 151 | KThread* thread = cur_node->thread; |
| 152 | if (thread->GetState() == ThreadState::Waiting) { | 152 | if (thread->GetState() == ThreadState::Waiting) { |
| 153 | thread->SetSyncedObject(this, result); | 153 | thread->SetSyncedObject(this, result); |
| 154 | thread->SetState(ThreadState::Runnable); | 154 | thread->SetState(ThreadState::Runnable); |
| @@ -156,8 +156,8 @@ void KSynchronizationObject::NotifyAvailable(ResultCode result) { | |||
| 156 | } | 156 | } |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | std::vector<Thread*> KSynchronizationObject::GetWaitingThreadsForDebugging() const { | 159 | std::vector<KThread*> KSynchronizationObject::GetWaitingThreadsForDebugging() const { |
| 160 | std::vector<Thread*> threads; | 160 | std::vector<KThread*> threads; |
| 161 | 161 | ||
| 162 | // If debugging, dump the list of waiters. | 162 | // If debugging, dump the list of waiters. |
| 163 | { | 163 | { |
diff --git a/src/core/hle/kernel/k_synchronization_object.h b/src/core/hle/kernel/k_synchronization_object.h index 14d80ebf1..f65c71c28 100644 --- a/src/core/hle/kernel/k_synchronization_object.h +++ b/src/core/hle/kernel/k_synchronization_object.h | |||
| @@ -13,14 +13,14 @@ namespace Kernel { | |||
| 13 | 13 | ||
| 14 | class KernelCore; | 14 | class KernelCore; |
| 15 | class Synchronization; | 15 | class Synchronization; |
| 16 | class Thread; | 16 | class KThread; |
| 17 | 17 | ||
| 18 | /// Class that represents a Kernel object that a thread can be waiting on | 18 | /// Class that represents a Kernel object that a thread can be waiting on |
| 19 | class KSynchronizationObject : public Object { | 19 | class KSynchronizationObject : public Object { |
| 20 | public: | 20 | public: |
| 21 | struct ThreadListNode { | 21 | struct ThreadListNode { |
| 22 | ThreadListNode* next{}; | 22 | ThreadListNode* next{}; |
| 23 | Thread* thread{}; | 23 | KThread* thread{}; |
| 24 | }; | 24 | }; |
| 25 | 25 | ||
| 26 | [[nodiscard]] static ResultCode Wait(KernelCore& kernel, s32* out_index, | 26 | [[nodiscard]] static ResultCode Wait(KernelCore& kernel, s32* out_index, |
| @@ -29,7 +29,7 @@ public: | |||
| 29 | 29 | ||
| 30 | [[nodiscard]] virtual bool IsSignaled() const = 0; | 30 | [[nodiscard]] virtual bool IsSignaled() const = 0; |
| 31 | 31 | ||
| 32 | [[nodiscard]] std::vector<Thread*> GetWaitingThreadsForDebugging() const; | 32 | [[nodiscard]] std::vector<KThread*> GetWaitingThreadsForDebugging() const; |
| 33 | 33 | ||
| 34 | protected: | 34 | protected: |
| 35 | explicit KSynchronizationObject(KernelCore& kernel); | 35 | explicit KSynchronizationObject(KernelCore& kernel); |
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/k_thread.cpp index d97323255..1ec29636c 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/k_thread.cpp | |||
| @@ -20,11 +20,11 @@ | |||
| 20 | #include "core/hle/kernel/k_condition_variable.h" | 20 | #include "core/hle/kernel/k_condition_variable.h" |
| 21 | #include "core/hle/kernel/k_scheduler.h" | 21 | #include "core/hle/kernel/k_scheduler.h" |
| 22 | #include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h" | 22 | #include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h" |
| 23 | #include "core/hle/kernel/k_thread.h" | ||
| 23 | #include "core/hle/kernel/kernel.h" | 24 | #include "core/hle/kernel/kernel.h" |
| 24 | #include "core/hle/kernel/memory/memory_layout.h" | 25 | #include "core/hle/kernel/memory/memory_layout.h" |
| 25 | #include "core/hle/kernel/object.h" | 26 | #include "core/hle/kernel/object.h" |
| 26 | #include "core/hle/kernel/process.h" | 27 | #include "core/hle/kernel/process.h" |
| 27 | #include "core/hle/kernel/thread.h" | ||
| 28 | #include "core/hle/kernel/time_manager.h" | 28 | #include "core/hle/kernel/time_manager.h" |
| 29 | #include "core/hle/result.h" | 29 | #include "core/hle/result.h" |
| 30 | #include "core/memory.h" | 30 | #include "core/memory.h" |
| @@ -36,14 +36,14 @@ | |||
| 36 | 36 | ||
| 37 | namespace Kernel { | 37 | namespace Kernel { |
| 38 | 38 | ||
| 39 | bool Thread::IsSignaled() const { | 39 | bool KThread::IsSignaled() const { |
| 40 | return signaled; | 40 | return signaled; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | Thread::Thread(KernelCore& kernel) : KSynchronizationObject{kernel} {} | 43 | KThread::KThread(KernelCore& kernel) : KSynchronizationObject{kernel} {} |
| 44 | Thread::~Thread() = default; | 44 | KThread::~KThread() = default; |
| 45 | 45 | ||
| 46 | void Thread::Stop() { | 46 | void KThread::Stop() { |
| 47 | { | 47 | { |
| 48 | KScopedSchedulerLock lock(kernel); | 48 | KScopedSchedulerLock lock(kernel); |
| 49 | SetState(ThreadState::Terminated); | 49 | SetState(ThreadState::Terminated); |
| @@ -62,18 +62,18 @@ void Thread::Stop() { | |||
| 62 | global_handle = 0; | 62 | global_handle = 0; |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | void Thread::Wakeup() { | 65 | void KThread::Wakeup() { |
| 66 | KScopedSchedulerLock lock(kernel); | 66 | KScopedSchedulerLock lock(kernel); |
| 67 | SetState(ThreadState::Runnable); | 67 | SetState(ThreadState::Runnable); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | ResultCode Thread::Start() { | 70 | ResultCode KThread::Start() { |
| 71 | KScopedSchedulerLock lock(kernel); | 71 | KScopedSchedulerLock lock(kernel); |
| 72 | SetState(ThreadState::Runnable); | 72 | SetState(ThreadState::Runnable); |
| 73 | return RESULT_SUCCESS; | 73 | return RESULT_SUCCESS; |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | void Thread::CancelWait() { | 76 | void KThread::CancelWait() { |
| 77 | KScopedSchedulerLock lock(kernel); | 77 | KScopedSchedulerLock lock(kernel); |
| 78 | if (GetState() != ThreadState::Waiting || !is_cancellable) { | 78 | if (GetState() != ThreadState::Waiting || !is_cancellable) { |
| 79 | is_sync_cancelled = true; | 79 | is_sync_cancelled = true; |
| @@ -103,26 +103,26 @@ static void ResetThreadContext64(Core::ARM_Interface::ThreadContext64& context, | |||
| 103 | context.fpcr = 0; | 103 | context.fpcr = 0; |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | std::shared_ptr<Common::Fiber>& Thread::GetHostContext() { | 106 | std::shared_ptr<Common::Fiber>& KThread::GetHostContext() { |
| 107 | return host_context; | 107 | return host_context; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | ResultVal<std::shared_ptr<Thread>> Thread::Create(Core::System& system, ThreadType type_flags, | 110 | ResultVal<std::shared_ptr<KThread>> KThread::Create(Core::System& system, ThreadType type_flags, |
| 111 | std::string name, VAddr entry_point, u32 priority, | 111 | std::string name, VAddr entry_point, |
| 112 | u64 arg, s32 processor_id, VAddr stack_top, | 112 | u32 priority, u64 arg, s32 processor_id, |
| 113 | Process* owner_process) { | 113 | VAddr stack_top, Process* owner_process) { |
| 114 | std::function<void(void*)> init_func = Core::CpuManager::GetGuestThreadStartFunc(); | 114 | std::function<void(void*)> init_func = Core::CpuManager::GetGuestThreadStartFunc(); |
| 115 | void* init_func_parameter = system.GetCpuManager().GetStartFuncParamater(); | 115 | void* init_func_parameter = system.GetCpuManager().GetStartFuncParamater(); |
| 116 | return Create(system, type_flags, name, entry_point, priority, arg, processor_id, stack_top, | 116 | return Create(system, type_flags, name, entry_point, priority, arg, processor_id, stack_top, |
| 117 | owner_process, std::move(init_func), init_func_parameter); | 117 | owner_process, std::move(init_func), init_func_parameter); |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | ResultVal<std::shared_ptr<Thread>> Thread::Create(Core::System& system, ThreadType type_flags, | 120 | ResultVal<std::shared_ptr<KThread>> KThread::Create(Core::System& system, ThreadType type_flags, |
| 121 | std::string name, VAddr entry_point, u32 priority, | 121 | std::string name, VAddr entry_point, |
| 122 | u64 arg, s32 processor_id, VAddr stack_top, | 122 | u32 priority, u64 arg, s32 processor_id, |
| 123 | Process* owner_process, | 123 | VAddr stack_top, Process* owner_process, |
| 124 | std::function<void(void*)>&& thread_start_func, | 124 | std::function<void(void*)>&& thread_start_func, |
| 125 | void* thread_start_parameter) { | 125 | void* thread_start_parameter) { |
| 126 | auto& kernel = system.Kernel(); | 126 | auto& kernel = system.Kernel(); |
| 127 | // Check if priority is in ranged. Lowest priority -> highest priority id. | 127 | // Check if priority is in ranged. Lowest priority -> highest priority id. |
| 128 | if (priority > THREADPRIO_LOWEST && ((type_flags & THREADTYPE_IDLE) == 0)) { | 128 | if (priority > THREADPRIO_LOWEST && ((type_flags & THREADTYPE_IDLE) == 0)) { |
| @@ -143,7 +143,7 @@ ResultVal<std::shared_ptr<Thread>> Thread::Create(Core::System& system, ThreadTy | |||
| 143 | } | 143 | } |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | std::shared_ptr<Thread> thread = std::make_shared<Thread>(kernel); | 146 | std::shared_ptr<KThread> thread = std::make_shared<KThread>(kernel); |
| 147 | 147 | ||
| 148 | thread->thread_id = kernel.CreateNewThreadID(); | 148 | thread->thread_id = kernel.CreateNewThreadID(); |
| 149 | thread->thread_state = ThreadState::Initialized; | 149 | thread->thread_state = ThreadState::Initialized; |
| @@ -185,10 +185,10 @@ ResultVal<std::shared_ptr<Thread>> Thread::Create(Core::System& system, ThreadTy | |||
| 185 | thread->host_context = | 185 | thread->host_context = |
| 186 | std::make_shared<Common::Fiber>(std::move(thread_start_func), thread_start_parameter); | 186 | std::make_shared<Common::Fiber>(std::move(thread_start_func), thread_start_parameter); |
| 187 | 187 | ||
| 188 | return MakeResult<std::shared_ptr<Thread>>(std::move(thread)); | 188 | return MakeResult<std::shared_ptr<KThread>>(std::move(thread)); |
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | void Thread::SetBasePriority(u32 priority) { | 191 | void KThread::SetBasePriority(u32 priority) { |
| 192 | ASSERT_MSG(priority <= THREADPRIO_LOWEST && priority >= THREADPRIO_HIGHEST, | 192 | ASSERT_MSG(priority <= THREADPRIO_LOWEST && priority >= THREADPRIO_HIGHEST, |
| 193 | "Invalid priority value."); | 193 | "Invalid priority value."); |
| 194 | 194 | ||
| @@ -201,18 +201,18 @@ void Thread::SetBasePriority(u32 priority) { | |||
| 201 | RestorePriority(kernel, this); | 201 | RestorePriority(kernel, this); |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | void Thread::SetSynchronizationResults(KSynchronizationObject* object, ResultCode result) { | 204 | void KThread::SetSynchronizationResults(KSynchronizationObject* object, ResultCode result) { |
| 205 | signaling_object = object; | 205 | signaling_object = object; |
| 206 | signaling_result = result; | 206 | signaling_result = result; |
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | VAddr Thread::GetCommandBufferAddress() const { | 209 | VAddr KThread::GetCommandBufferAddress() const { |
| 210 | // Offset from the start of TLS at which the IPC command buffer begins. | 210 | // Offset from the start of TLS at which the IPC command buffer begins. |
| 211 | constexpr u64 command_header_offset = 0x80; | 211 | constexpr u64 command_header_offset = 0x80; |
| 212 | return GetTLSAddress() + command_header_offset; | 212 | return GetTLSAddress() + command_header_offset; |
| 213 | } | 213 | } |
| 214 | 214 | ||
| 215 | void Thread::SetState(ThreadState state) { | 215 | void KThread::SetState(ThreadState state) { |
| 216 | KScopedSchedulerLock sl(kernel); | 216 | KScopedSchedulerLock sl(kernel); |
| 217 | 217 | ||
| 218 | // Clear debugging state | 218 | // Clear debugging state |
| @@ -227,7 +227,7 @@ void Thread::SetState(ThreadState state) { | |||
| 227 | } | 227 | } |
| 228 | } | 228 | } |
| 229 | 229 | ||
| 230 | void Thread::AddWaiterImpl(Thread* thread) { | 230 | void KThread::AddWaiterImpl(KThread* thread) { |
| 231 | ASSERT(kernel.GlobalSchedulerContext().IsLocked()); | 231 | ASSERT(kernel.GlobalSchedulerContext().IsLocked()); |
| 232 | 232 | ||
| 233 | // Find the right spot to insert the waiter. | 233 | // Find the right spot to insert the waiter. |
| @@ -249,7 +249,7 @@ void Thread::AddWaiterImpl(Thread* thread) { | |||
| 249 | thread->SetLockOwner(this); | 249 | thread->SetLockOwner(this); |
| 250 | } | 250 | } |
| 251 | 251 | ||
| 252 | void Thread::RemoveWaiterImpl(Thread* thread) { | 252 | void KThread::RemoveWaiterImpl(KThread* thread) { |
| 253 | ASSERT(kernel.GlobalSchedulerContext().IsLocked()); | 253 | ASSERT(kernel.GlobalSchedulerContext().IsLocked()); |
| 254 | 254 | ||
| 255 | // Keep track of how many kernel waiters we have. | 255 | // Keep track of how many kernel waiters we have. |
| @@ -262,7 +262,7 @@ void Thread::RemoveWaiterImpl(Thread* thread) { | |||
| 262 | thread->SetLockOwner(nullptr); | 262 | thread->SetLockOwner(nullptr); |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | void Thread::RestorePriority(KernelCore& kernel, Thread* thread) { | 265 | void KThread::RestorePriority(KernelCore& kernel, KThread* thread) { |
| 266 | ASSERT(kernel.GlobalSchedulerContext().IsLocked()); | 266 | ASSERT(kernel.GlobalSchedulerContext().IsLocked()); |
| 267 | 267 | ||
| 268 | while (true) { | 268 | while (true) { |
| @@ -295,7 +295,7 @@ void Thread::RestorePriority(KernelCore& kernel, Thread* thread) { | |||
| 295 | KScheduler::OnThreadPriorityChanged(kernel, thread, old_priority); | 295 | KScheduler::OnThreadPriorityChanged(kernel, thread, old_priority); |
| 296 | 296 | ||
| 297 | // Keep the lock owner up to date. | 297 | // Keep the lock owner up to date. |
| 298 | Thread* lock_owner = thread->GetLockOwner(); | 298 | KThread* lock_owner = thread->GetLockOwner(); |
| 299 | if (lock_owner == nullptr) { | 299 | if (lock_owner == nullptr) { |
| 300 | return; | 300 | return; |
| 301 | } | 301 | } |
| @@ -307,25 +307,25 @@ void Thread::RestorePriority(KernelCore& kernel, Thread* thread) { | |||
| 307 | } | 307 | } |
| 308 | } | 308 | } |
| 309 | 309 | ||
| 310 | void Thread::AddWaiter(Thread* thread) { | 310 | void KThread::AddWaiter(KThread* thread) { |
| 311 | AddWaiterImpl(thread); | 311 | AddWaiterImpl(thread); |
| 312 | RestorePriority(kernel, this); | 312 | RestorePriority(kernel, this); |
| 313 | } | 313 | } |
| 314 | 314 | ||
| 315 | void Thread::RemoveWaiter(Thread* thread) { | 315 | void KThread::RemoveWaiter(KThread* thread) { |
| 316 | RemoveWaiterImpl(thread); | 316 | RemoveWaiterImpl(thread); |
| 317 | RestorePriority(kernel, this); | 317 | RestorePriority(kernel, this); |
| 318 | } | 318 | } |
| 319 | 319 | ||
| 320 | Thread* Thread::RemoveWaiterByKey(s32* out_num_waiters, VAddr key) { | 320 | KThread* KThread::RemoveWaiterByKey(s32* out_num_waiters, VAddr key) { |
| 321 | ASSERT(kernel.GlobalSchedulerContext().IsLocked()); | 321 | ASSERT(kernel.GlobalSchedulerContext().IsLocked()); |
| 322 | 322 | ||
| 323 | s32 num_waiters{}; | 323 | s32 num_waiters{}; |
| 324 | Thread* next_lock_owner{}; | 324 | KThread* next_lock_owner{}; |
| 325 | auto it = waiter_list.begin(); | 325 | auto it = waiter_list.begin(); |
| 326 | while (it != waiter_list.end()) { | 326 | while (it != waiter_list.end()) { |
| 327 | if (it->GetAddressKey() == key) { | 327 | if (it->GetAddressKey() == key) { |
| 328 | Thread* thread = std::addressof(*it); | 328 | KThread* thread = std::addressof(*it); |
| 329 | 329 | ||
| 330 | // Keep track of how many kernel waiters we have. | 330 | // Keep track of how many kernel waiters we have. |
| 331 | if (Memory::IsKernelAddressKey(thread->GetAddressKey())) { | 331 | if (Memory::IsKernelAddressKey(thread->GetAddressKey())) { |
| @@ -357,7 +357,7 @@ Thread* Thread::RemoveWaiterByKey(s32* out_num_waiters, VAddr key) { | |||
| 357 | return next_lock_owner; | 357 | return next_lock_owner; |
| 358 | } | 358 | } |
| 359 | 359 | ||
| 360 | ResultCode Thread::SetActivity(ThreadActivity value) { | 360 | ResultCode KThread::SetActivity(ThreadActivity value) { |
| 361 | KScopedSchedulerLock lock(kernel); | 361 | KScopedSchedulerLock lock(kernel); |
| 362 | 362 | ||
| 363 | auto sched_status = GetState(); | 363 | auto sched_status = GetState(); |
| @@ -384,7 +384,7 @@ ResultCode Thread::SetActivity(ThreadActivity value) { | |||
| 384 | return RESULT_SUCCESS; | 384 | return RESULT_SUCCESS; |
| 385 | } | 385 | } |
| 386 | 386 | ||
| 387 | ResultCode Thread::Sleep(s64 nanoseconds) { | 387 | ResultCode KThread::Sleep(s64 nanoseconds) { |
| 388 | Handle event_handle{}; | 388 | Handle event_handle{}; |
| 389 | { | 389 | { |
| 390 | KScopedSchedulerLockAndSleep lock(kernel, event_handle, this, nanoseconds); | 390 | KScopedSchedulerLockAndSleep lock(kernel, event_handle, this, nanoseconds); |
| @@ -399,7 +399,7 @@ ResultCode Thread::Sleep(s64 nanoseconds) { | |||
| 399 | return RESULT_SUCCESS; | 399 | return RESULT_SUCCESS; |
| 400 | } | 400 | } |
| 401 | 401 | ||
| 402 | void Thread::AddSchedulingFlag(ThreadSchedFlags flag) { | 402 | void KThread::AddSchedulingFlag(ThreadSchedFlags flag) { |
| 403 | const auto old_state = GetRawState(); | 403 | const auto old_state = GetRawState(); |
| 404 | pausing_state |= static_cast<u32>(flag); | 404 | pausing_state |= static_cast<u32>(flag); |
| 405 | const auto base_scheduling = GetState(); | 405 | const auto base_scheduling = GetState(); |
| @@ -407,7 +407,7 @@ void Thread::AddSchedulingFlag(ThreadSchedFlags flag) { | |||
| 407 | KScheduler::OnThreadStateChanged(kernel, this, old_state); | 407 | KScheduler::OnThreadStateChanged(kernel, this, old_state); |
| 408 | } | 408 | } |
| 409 | 409 | ||
| 410 | void Thread::RemoveSchedulingFlag(ThreadSchedFlags flag) { | 410 | void KThread::RemoveSchedulingFlag(ThreadSchedFlags flag) { |
| 411 | const auto old_state = GetRawState(); | 411 | const auto old_state = GetRawState(); |
| 412 | pausing_state &= ~static_cast<u32>(flag); | 412 | pausing_state &= ~static_cast<u32>(flag); |
| 413 | const auto base_scheduling = GetState(); | 413 | const auto base_scheduling = GetState(); |
| @@ -415,7 +415,7 @@ void Thread::RemoveSchedulingFlag(ThreadSchedFlags flag) { | |||
| 415 | KScheduler::OnThreadStateChanged(kernel, this, old_state); | 415 | KScheduler::OnThreadStateChanged(kernel, this, old_state); |
| 416 | } | 416 | } |
| 417 | 417 | ||
| 418 | ResultCode Thread::SetCoreAndAffinityMask(s32 new_core, u64 new_affinity_mask) { | 418 | ResultCode KThread::SetCoreAndAffinityMask(s32 new_core, u64 new_affinity_mask) { |
| 419 | KScopedSchedulerLock lock(kernel); | 419 | KScopedSchedulerLock lock(kernel); |
| 420 | const auto HighestSetCore = [](u64 mask, u32 max_cores) { | 420 | const auto HighestSetCore = [](u64 mask, u32 max_cores) { |
| 421 | for (s32 core = static_cast<s32>(max_cores - 1); core >= 0; core--) { | 421 | for (s32 core = static_cast<s32>(max_cores - 1); core >= 0; core--) { |
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/k_thread.h index 6b66c9a0e..75257d2b4 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/k_thread.h | |||
| @@ -124,15 +124,15 @@ enum class ThreadWaitReasonForDebugging : u32 { | |||
| 124 | Suspended, ///< Thread is waiting due to process suspension | 124 | Suspended, ///< Thread is waiting due to process suspension |
| 125 | }; | 125 | }; |
| 126 | 126 | ||
| 127 | class Thread final : public KSynchronizationObject, public boost::intrusive::list_base_hook<> { | 127 | class KThread final : public KSynchronizationObject, public boost::intrusive::list_base_hook<> { |
| 128 | friend class KScheduler; | 128 | friend class KScheduler; |
| 129 | friend class Process; | 129 | friend class Process; |
| 130 | 130 | ||
| 131 | public: | 131 | public: |
| 132 | explicit Thread(KernelCore& kernel); | 132 | explicit KThread(KernelCore& kernel); |
| 133 | ~Thread() override; | 133 | ~KThread() override; |
| 134 | 134 | ||
| 135 | using MutexWaitingThreads = std::vector<std::shared_ptr<Thread>>; | 135 | using MutexWaitingThreads = std::vector<std::shared_ptr<KThread>>; |
| 136 | 136 | ||
| 137 | using ThreadContext32 = Core::ARM_Interface::ThreadContext32; | 137 | using ThreadContext32 = Core::ARM_Interface::ThreadContext32; |
| 138 | using ThreadContext64 = Core::ARM_Interface::ThreadContext64; | 138 | using ThreadContext64 = Core::ARM_Interface::ThreadContext64; |
| @@ -149,10 +149,10 @@ public: | |||
| 149 | * @param owner_process The parent process for the thread, if null, it's a kernel thread | 149 | * @param owner_process The parent process for the thread, if null, it's a kernel thread |
| 150 | * @return A shared pointer to the newly created thread | 150 | * @return A shared pointer to the newly created thread |
| 151 | */ | 151 | */ |
| 152 | static ResultVal<std::shared_ptr<Thread>> Create(Core::System& system, ThreadType type_flags, | 152 | static ResultVal<std::shared_ptr<KThread>> Create(Core::System& system, ThreadType type_flags, |
| 153 | std::string name, VAddr entry_point, | 153 | std::string name, VAddr entry_point, |
| 154 | u32 priority, u64 arg, s32 processor_id, | 154 | u32 priority, u64 arg, s32 processor_id, |
| 155 | VAddr stack_top, Process* owner_process); | 155 | VAddr stack_top, Process* owner_process); |
| 156 | 156 | ||
| 157 | /** | 157 | /** |
| 158 | * Creates and returns a new thread. The new thread is immediately scheduled | 158 | * Creates and returns a new thread. The new thread is immediately scheduled |
| @@ -168,12 +168,10 @@ public: | |||
| 168 | * @param thread_start_parameter The parameter which will passed to host context on init | 168 | * @param thread_start_parameter The parameter which will passed to host context on init |
| 169 | * @return A shared pointer to the newly created thread | 169 | * @return A shared pointer to the newly created thread |
| 170 | */ | 170 | */ |
| 171 | static ResultVal<std::shared_ptr<Thread>> Create(Core::System& system, ThreadType type_flags, | 171 | static ResultVal<std::shared_ptr<KThread>> Create( |
| 172 | std::string name, VAddr entry_point, | 172 | Core::System& system, ThreadType type_flags, std::string name, VAddr entry_point, |
| 173 | u32 priority, u64 arg, s32 processor_id, | 173 | u32 priority, u64 arg, s32 processor_id, VAddr stack_top, Process* owner_process, |
| 174 | VAddr stack_top, Process* owner_process, | 174 | std::function<void(void*)>&& thread_start_func, void* thread_start_parameter); |
| 175 | std::function<void(void*)>&& thread_start_func, | ||
| 176 | void* thread_start_parameter); | ||
| 177 | 175 | ||
| 178 | std::string GetName() const override { | 176 | std::string GetName() const override { |
| 179 | return name; | 177 | return name; |
| @@ -387,11 +385,11 @@ public: | |||
| 387 | return wait_mutex_threads; | 385 | return wait_mutex_threads; |
| 388 | } | 386 | } |
| 389 | 387 | ||
| 390 | Thread* GetLockOwner() const { | 388 | KThread* GetLockOwner() const { |
| 391 | return lock_owner; | 389 | return lock_owner; |
| 392 | } | 390 | } |
| 393 | 391 | ||
| 394 | void SetLockOwner(Thread* owner) { | 392 | void SetLockOwner(KThread* owner) { |
| 395 | lock_owner = owner; | 393 | lock_owner = owner; |
| 396 | } | 394 | } |
| 397 | 395 | ||
| @@ -485,22 +483,22 @@ public: | |||
| 485 | next = nullptr; | 483 | next = nullptr; |
| 486 | } | 484 | } |
| 487 | 485 | ||
| 488 | constexpr Thread* GetPrev() const { | 486 | constexpr KThread* GetPrev() const { |
| 489 | return prev; | 487 | return prev; |
| 490 | } | 488 | } |
| 491 | constexpr Thread* GetNext() const { | 489 | constexpr KThread* GetNext() const { |
| 492 | return next; | 490 | return next; |
| 493 | } | 491 | } |
| 494 | constexpr void SetPrev(Thread* thread) { | 492 | constexpr void SetPrev(KThread* thread) { |
| 495 | prev = thread; | 493 | prev = thread; |
| 496 | } | 494 | } |
| 497 | constexpr void SetNext(Thread* thread) { | 495 | constexpr void SetNext(KThread* thread) { |
| 498 | next = thread; | 496 | next = thread; |
| 499 | } | 497 | } |
| 500 | 498 | ||
| 501 | private: | 499 | private: |
| 502 | Thread* prev{}; | 500 | KThread* prev{}; |
| 503 | Thread* next{}; | 501 | KThread* next{}; |
| 504 | }; | 502 | }; |
| 505 | 503 | ||
| 506 | QueueEntry& GetPriorityQueueEntry(s32 core) { | 504 | QueueEntry& GetPriorityQueueEntry(s32 core) { |
| @@ -553,11 +551,11 @@ public: | |||
| 553 | return mutex_wait_address_for_debugging; | 551 | return mutex_wait_address_for_debugging; |
| 554 | } | 552 | } |
| 555 | 553 | ||
| 556 | void AddWaiter(Thread* thread); | 554 | void AddWaiter(KThread* thread); |
| 557 | 555 | ||
| 558 | void RemoveWaiter(Thread* thread); | 556 | void RemoveWaiter(KThread* thread); |
| 559 | 557 | ||
| 560 | [[nodiscard]] Thread* RemoveWaiterByKey(s32* out_num_waiters, VAddr key); | 558 | [[nodiscard]] KThread* RemoveWaiterByKey(s32* out_num_waiters, VAddr key); |
| 561 | 559 | ||
| 562 | [[nodiscard]] VAddr GetAddressKey() const { | 560 | [[nodiscard]] VAddr GetAddressKey() const { |
| 563 | return address_key; | 561 | return address_key; |
| @@ -603,9 +601,9 @@ private: | |||
| 603 | 601 | ||
| 604 | template <typename T> | 602 | template <typename T> |
| 605 | requires( | 603 | requires( |
| 606 | std::same_as<T, Thread> || | 604 | std::same_as<T, KThread> || |
| 607 | std::same_as<T, LightCompareType>) static constexpr int Compare(const T& lhs, | 605 | std::same_as<T, LightCompareType>) static constexpr int Compare(const T& lhs, |
| 608 | const Thread& rhs) { | 606 | const KThread& rhs) { |
| 609 | const uintptr_t l_key = lhs.GetConditionVariableKey(); | 607 | const uintptr_t l_key = lhs.GetConditionVariableKey(); |
| 610 | const uintptr_t r_key = rhs.GetConditionVariableKey(); | 608 | const uintptr_t r_key = rhs.GetConditionVariableKey(); |
| 611 | 609 | ||
| @@ -624,7 +622,8 @@ private: | |||
| 624 | Common::IntrusiveRedBlackTreeNode condvar_arbiter_tree_node{}; | 622 | Common::IntrusiveRedBlackTreeNode condvar_arbiter_tree_node{}; |
| 625 | 623 | ||
| 626 | using ConditionVariableThreadTreeTraits = | 624 | using ConditionVariableThreadTreeTraits = |
| 627 | Common::IntrusiveRedBlackTreeMemberTraitsDeferredAssert<&Thread::condvar_arbiter_tree_node>; | 625 | Common::IntrusiveRedBlackTreeMemberTraitsDeferredAssert< |
| 626 | &KThread::condvar_arbiter_tree_node>; | ||
| 628 | using ConditionVariableThreadTree = | 627 | using ConditionVariableThreadTree = |
| 629 | ConditionVariableThreadTreeTraits::TreeType<ConditionVariableComparator>; | 628 | ConditionVariableThreadTreeTraits::TreeType<ConditionVariableComparator>; |
| 630 | 629 | ||
| @@ -679,9 +678,9 @@ public: | |||
| 679 | private: | 678 | private: |
| 680 | void AddSchedulingFlag(ThreadSchedFlags flag); | 679 | void AddSchedulingFlag(ThreadSchedFlags flag); |
| 681 | void RemoveSchedulingFlag(ThreadSchedFlags flag); | 680 | void RemoveSchedulingFlag(ThreadSchedFlags flag); |
| 682 | void AddWaiterImpl(Thread* thread); | 681 | void AddWaiterImpl(KThread* thread); |
| 683 | void RemoveWaiterImpl(Thread* thread); | 682 | void RemoveWaiterImpl(KThread* thread); |
| 684 | static void RestorePriority(KernelCore& kernel, Thread* thread); | 683 | static void RestorePriority(KernelCore& kernel, KThread* thread); |
| 685 | 684 | ||
| 686 | Common::SpinLock context_guard{}; | 685 | Common::SpinLock context_guard{}; |
| 687 | ThreadContext32 context_32{}; | 686 | ThreadContext32 context_32{}; |
| @@ -736,7 +735,7 @@ private: | |||
| 736 | MutexWaitingThreads wait_mutex_threads; | 735 | MutexWaitingThreads wait_mutex_threads; |
| 737 | 736 | ||
| 738 | /// Thread that owns the lock that this thread is waiting for. | 737 | /// Thread that owns the lock that this thread is waiting for. |
| 739 | Thread* lock_owner{}; | 738 | KThread* lock_owner{}; |
| 740 | 739 | ||
| 741 | /// Handle used as userdata to reference this object when inserting into the CoreTiming queue. | 740 | /// Handle used as userdata to reference this object when inserting into the CoreTiming queue. |
| 742 | Handle global_handle = 0; | 741 | Handle global_handle = 0; |
| @@ -772,7 +771,7 @@ private: | |||
| 772 | u32 address_key_value{}; | 771 | u32 address_key_value{}; |
| 773 | s32 num_kernel_waiters{}; | 772 | s32 num_kernel_waiters{}; |
| 774 | 773 | ||
| 775 | using WaiterList = boost::intrusive::list<Thread>; | 774 | using WaiterList = boost::intrusive::list<KThread>; |
| 776 | WaiterList waiter_list{}; | 775 | WaiterList waiter_list{}; |
| 777 | WaiterList pinned_waiter_list{}; | 776 | WaiterList pinned_waiter_list{}; |
| 778 | 777 | ||
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index c0ff287a6..523dd63a5 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -29,6 +29,7 @@ | |||
| 29 | #include "core/hle/kernel/errors.h" | 29 | #include "core/hle/kernel/errors.h" |
| 30 | #include "core/hle/kernel/handle_table.h" | 30 | #include "core/hle/kernel/handle_table.h" |
| 31 | #include "core/hle/kernel/k_scheduler.h" | 31 | #include "core/hle/kernel/k_scheduler.h" |
| 32 | #include "core/hle/kernel/k_thread.h" | ||
| 32 | #include "core/hle/kernel/kernel.h" | 33 | #include "core/hle/kernel/kernel.h" |
| 33 | #include "core/hle/kernel/memory/memory_layout.h" | 34 | #include "core/hle/kernel/memory/memory_layout.h" |
| 34 | #include "core/hle/kernel/memory/memory_manager.h" | 35 | #include "core/hle/kernel/memory/memory_manager.h" |
| @@ -38,7 +39,6 @@ | |||
| 38 | #include "core/hle/kernel/resource_limit.h" | 39 | #include "core/hle/kernel/resource_limit.h" |
| 39 | #include "core/hle/kernel/service_thread.h" | 40 | #include "core/hle/kernel/service_thread.h" |
| 40 | #include "core/hle/kernel/shared_memory.h" | 41 | #include "core/hle/kernel/shared_memory.h" |
| 41 | #include "core/hle/kernel/thread.h" | ||
| 42 | #include "core/hle/kernel/time_manager.h" | 42 | #include "core/hle/kernel/time_manager.h" |
| 43 | #include "core/hle/lock.h" | 43 | #include "core/hle/lock.h" |
| 44 | #include "core/hle/result.h" | 44 | #include "core/hle/result.h" |
| @@ -171,8 +171,8 @@ struct KernelCore::Impl { | |||
| 171 | const auto type = | 171 | const auto type = |
| 172 | static_cast<ThreadType>(THREADTYPE_KERNEL | THREADTYPE_HLE | THREADTYPE_SUSPEND); | 172 | static_cast<ThreadType>(THREADTYPE_KERNEL | THREADTYPE_HLE | THREADTYPE_SUSPEND); |
| 173 | auto thread_res = | 173 | auto thread_res = |
| 174 | Thread::Create(system, type, std::move(name), 0, 0, 0, static_cast<u32>(i), 0, | 174 | KThread::Create(system, type, std::move(name), 0, 0, 0, static_cast<u32>(i), 0, |
| 175 | nullptr, std::move(init_func), init_func_parameter); | 175 | nullptr, std::move(init_func), init_func_parameter); |
| 176 | 176 | ||
| 177 | suspend_threads[i] = std::move(thread_res).Unwrap(); | 177 | suspend_threads[i] = std::move(thread_res).Unwrap(); |
| 178 | } | 178 | } |
| @@ -236,7 +236,7 @@ struct KernelCore::Impl { | |||
| 236 | return result; | 236 | return result; |
| 237 | } | 237 | } |
| 238 | const Kernel::KScheduler& sched = cores[result.host_handle].Scheduler(); | 238 | const Kernel::KScheduler& sched = cores[result.host_handle].Scheduler(); |
| 239 | const Kernel::Thread* current = sched.GetCurrentThread(); | 239 | const Kernel::KThread* current = sched.GetCurrentThread(); |
| 240 | if (current != nullptr && !current->IsPhantomMode()) { | 240 | if (current != nullptr && !current->IsPhantomMode()) { |
| 241 | result.guest_handle = current->GetGlobalHandle(); | 241 | result.guest_handle = current->GetGlobalHandle(); |
| 242 | } else { | 242 | } else { |
| @@ -342,7 +342,7 @@ struct KernelCore::Impl { | |||
| 342 | // the release of itself | 342 | // the release of itself |
| 343 | std::unique_ptr<Common::ThreadWorker> service_thread_manager; | 343 | std::unique_ptr<Common::ThreadWorker> service_thread_manager; |
| 344 | 344 | ||
| 345 | std::array<std::shared_ptr<Thread>, Core::Hardware::NUM_CPU_CORES> suspend_threads{}; | 345 | std::array<std::shared_ptr<KThread>, Core::Hardware::NUM_CPU_CORES> suspend_threads{}; |
| 346 | std::array<Core::CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES> interrupts{}; | 346 | std::array<Core::CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES> interrupts{}; |
| 347 | std::array<std::unique_ptr<Kernel::KScheduler>, Core::Hardware::NUM_CPU_CORES> schedulers{}; | 347 | std::array<std::unique_ptr<Kernel::KScheduler>, Core::Hardware::NUM_CPU_CORES> schedulers{}; |
| 348 | 348 | ||
| @@ -380,8 +380,8 @@ std::shared_ptr<ResourceLimit> KernelCore::GetSystemResourceLimit() const { | |||
| 380 | return impl->system_resource_limit; | 380 | return impl->system_resource_limit; |
| 381 | } | 381 | } |
| 382 | 382 | ||
| 383 | std::shared_ptr<Thread> KernelCore::RetrieveThreadFromGlobalHandleTable(Handle handle) const { | 383 | std::shared_ptr<KThread> KernelCore::RetrieveThreadFromGlobalHandleTable(Handle handle) const { |
| 384 | return impl->global_handle_table.Get<Thread>(handle); | 384 | return impl->global_handle_table.Get<KThread>(handle); |
| 385 | } | 385 | } |
| 386 | 386 | ||
| 387 | void KernelCore::AppendNewProcess(std::shared_ptr<Process> process) { | 387 | void KernelCore::AppendNewProcess(std::shared_ptr<Process> process) { |
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 933d9a7d6..41c553582 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h | |||
| @@ -43,7 +43,7 @@ class KScheduler; | |||
| 43 | class SharedMemory; | 43 | class SharedMemory; |
| 44 | class ServiceThread; | 44 | class ServiceThread; |
| 45 | class Synchronization; | 45 | class Synchronization; |
| 46 | class Thread; | 46 | class KThread; |
| 47 | class TimeManager; | 47 | class TimeManager; |
| 48 | 48 | ||
| 49 | /// Represents a single instance of the kernel. | 49 | /// Represents a single instance of the kernel. |
| @@ -84,7 +84,7 @@ public: | |||
| 84 | std::shared_ptr<ResourceLimit> GetSystemResourceLimit() const; | 84 | std::shared_ptr<ResourceLimit> GetSystemResourceLimit() const; |
| 85 | 85 | ||
| 86 | /// Retrieves a shared pointer to a Thread instance within the thread wakeup handle table. | 86 | /// Retrieves a shared pointer to a Thread instance within the thread wakeup handle table. |
| 87 | std::shared_ptr<Thread> RetrieveThreadFromGlobalHandleTable(Handle handle) const; | 87 | std::shared_ptr<KThread> RetrieveThreadFromGlobalHandleTable(Handle handle) const; |
| 88 | 88 | ||
| 89 | /// Adds the given shared pointer to an internal list of active processes. | 89 | /// Adds the given shared pointer to an internal list of active processes. |
| 90 | void AppendNewProcess(std::shared_ptr<Process> process); | 90 | void AppendNewProcess(std::shared_ptr<Process> process); |
| @@ -240,7 +240,7 @@ public: | |||
| 240 | private: | 240 | private: |
| 241 | friend class Object; | 241 | friend class Object; |
| 242 | friend class Process; | 242 | friend class Process; |
| 243 | friend class Thread; | 243 | friend class KThread; |
| 244 | 244 | ||
| 245 | /// Creates a new object ID, incrementing the internal object ID counter. | 245 | /// Creates a new object ID, incrementing the internal object ID counter. |
| 246 | u32 CreateNewObjectID(); | 246 | u32 CreateNewObjectID(); |
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 37b77fa6e..ccd371aba 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp | |||
| @@ -16,13 +16,13 @@ | |||
| 16 | #include "core/hle/kernel/code_set.h" | 16 | #include "core/hle/kernel/code_set.h" |
| 17 | #include "core/hle/kernel/errors.h" | 17 | #include "core/hle/kernel/errors.h" |
| 18 | #include "core/hle/kernel/k_scheduler.h" | 18 | #include "core/hle/kernel/k_scheduler.h" |
| 19 | #include "core/hle/kernel/k_thread.h" | ||
| 19 | #include "core/hle/kernel/kernel.h" | 20 | #include "core/hle/kernel/kernel.h" |
| 20 | #include "core/hle/kernel/memory/memory_block_manager.h" | 21 | #include "core/hle/kernel/memory/memory_block_manager.h" |
| 21 | #include "core/hle/kernel/memory/page_table.h" | 22 | #include "core/hle/kernel/memory/page_table.h" |
| 22 | #include "core/hle/kernel/memory/slab_heap.h" | 23 | #include "core/hle/kernel/memory/slab_heap.h" |
| 23 | #include "core/hle/kernel/process.h" | 24 | #include "core/hle/kernel/process.h" |
| 24 | #include "core/hle/kernel/resource_limit.h" | 25 | #include "core/hle/kernel/resource_limit.h" |
| 25 | #include "core/hle/kernel/thread.h" | ||
| 26 | #include "core/hle/lock.h" | 26 | #include "core/hle/lock.h" |
| 27 | #include "core/memory.h" | 27 | #include "core/memory.h" |
| 28 | #include "core/settings.h" | 28 | #include "core/settings.h" |
| @@ -39,10 +39,10 @@ namespace { | |||
| 39 | void SetupMainThread(Core::System& system, Process& owner_process, u32 priority, VAddr stack_top) { | 39 | void SetupMainThread(Core::System& system, Process& owner_process, u32 priority, VAddr stack_top) { |
| 40 | const VAddr entry_point = owner_process.PageTable().GetCodeRegionStart(); | 40 | const VAddr entry_point = owner_process.PageTable().GetCodeRegionStart(); |
| 41 | ThreadType type = THREADTYPE_USER; | 41 | ThreadType type = THREADTYPE_USER; |
| 42 | auto thread_res = Thread::Create(system, type, "main", entry_point, priority, 0, | 42 | auto thread_res = KThread::Create(system, type, "main", entry_point, priority, 0, |
| 43 | owner_process.GetIdealCore(), stack_top, &owner_process); | 43 | owner_process.GetIdealCore(), stack_top, &owner_process); |
| 44 | 44 | ||
| 45 | std::shared_ptr<Thread> thread = std::move(thread_res).Unwrap(); | 45 | std::shared_ptr<KThread> thread = std::move(thread_res).Unwrap(); |
| 46 | 46 | ||
| 47 | // Register 1 must be a handle to the main thread | 47 | // Register 1 must be a handle to the main thread |
| 48 | const Handle thread_handle = owner_process.GetHandleTable().Create(thread).Unwrap(); | 48 | const Handle thread_handle = owner_process.GetHandleTable().Create(thread).Unwrap(); |
| @@ -162,11 +162,11 @@ u64 Process::GetTotalPhysicalMemoryUsedWithoutSystemResource() const { | |||
| 162 | return GetTotalPhysicalMemoryUsed() - GetSystemResourceUsage(); | 162 | return GetTotalPhysicalMemoryUsed() - GetSystemResourceUsage(); |
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | void Process::RegisterThread(const Thread* thread) { | 165 | void Process::RegisterThread(const KThread* thread) { |
| 166 | thread_list.push_back(thread); | 166 | thread_list.push_back(thread); |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | void Process::UnregisterThread(const Thread* thread) { | 169 | void Process::UnregisterThread(const KThread* thread) { |
| 170 | thread_list.remove(thread); | 170 | thread_list.remove(thread); |
| 171 | } | 171 | } |
| 172 | 172 | ||
| @@ -267,7 +267,7 @@ void Process::Run(s32 main_thread_priority, u64 stack_size) { | |||
| 267 | void Process::PrepareForTermination() { | 267 | void Process::PrepareForTermination() { |
| 268 | ChangeStatus(ProcessStatus::Exiting); | 268 | ChangeStatus(ProcessStatus::Exiting); |
| 269 | 269 | ||
| 270 | const auto stop_threads = [this](const std::vector<std::shared_ptr<Thread>>& thread_list) { | 270 | const auto stop_threads = [this](const std::vector<std::shared_ptr<KThread>>& thread_list) { |
| 271 | for (auto& thread : thread_list) { | 271 | for (auto& thread : thread_list) { |
| 272 | if (thread->GetOwnerProcess() != this) | 272 | if (thread->GetOwnerProcess() != this) |
| 273 | continue; | 273 | continue; |
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 564e1f27d..db01d6c8a 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h | |||
| @@ -30,7 +30,7 @@ namespace Kernel { | |||
| 30 | 30 | ||
| 31 | class KernelCore; | 31 | class KernelCore; |
| 32 | class ResourceLimit; | 32 | class ResourceLimit; |
| 33 | class Thread; | 33 | class KThread; |
| 34 | class TLSPage; | 34 | class TLSPage; |
| 35 | 35 | ||
| 36 | struct CodeSet; | 36 | struct CodeSet; |
| @@ -252,17 +252,17 @@ public: | |||
| 252 | u64 GetTotalPhysicalMemoryUsedWithoutSystemResource() const; | 252 | u64 GetTotalPhysicalMemoryUsedWithoutSystemResource() const; |
| 253 | 253 | ||
| 254 | /// Gets the list of all threads created with this process as their owner. | 254 | /// Gets the list of all threads created with this process as their owner. |
| 255 | const std::list<const Thread*>& GetThreadList() const { | 255 | const std::list<const KThread*>& GetThreadList() const { |
| 256 | return thread_list; | 256 | return thread_list; |
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | /// Registers a thread as being created under this process, | 259 | /// Registers a thread as being created under this process, |
| 260 | /// adding it to this process' thread list. | 260 | /// adding it to this process' thread list. |
| 261 | void RegisterThread(const Thread* thread); | 261 | void RegisterThread(const KThread* thread); |
| 262 | 262 | ||
| 263 | /// Unregisters a thread from this process, removing it | 263 | /// Unregisters a thread from this process, removing it |
| 264 | /// from this process' thread list. | 264 | /// from this process' thread list. |
| 265 | void UnregisterThread(const Thread* thread); | 265 | void UnregisterThread(const KThread* thread); |
| 266 | 266 | ||
| 267 | /// Clears the signaled state of the process if and only if it's signaled. | 267 | /// Clears the signaled state of the process if and only if it's signaled. |
| 268 | /// | 268 | /// |
| @@ -380,7 +380,7 @@ private: | |||
| 380 | std::array<u64, RANDOM_ENTROPY_SIZE> random_entropy{}; | 380 | std::array<u64, RANDOM_ENTROPY_SIZE> random_entropy{}; |
| 381 | 381 | ||
| 382 | /// List of threads that are running with this process as their owner. | 382 | /// List of threads that are running with this process as their owner. |
| 383 | std::list<const Thread*> thread_list; | 383 | std::list<const KThread*> thread_list; |
| 384 | 384 | ||
| 385 | /// Address of the top of the main thread's stack | 385 | /// Address of the top of the main thread's stack |
| 386 | VAddr main_thread_stack_top{}; | 386 | VAddr main_thread_stack_top{}; |
diff --git a/src/core/hle/kernel/readable_event.cpp b/src/core/hle/kernel/readable_event.cpp index 99ed0857e..596d01479 100644 --- a/src/core/hle/kernel/readable_event.cpp +++ b/src/core/hle/kernel/readable_event.cpp | |||
| @@ -7,10 +7,10 @@ | |||
| 7 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 8 | #include "core/hle/kernel/errors.h" | 8 | #include "core/hle/kernel/errors.h" |
| 9 | #include "core/hle/kernel/k_scheduler.h" | 9 | #include "core/hle/kernel/k_scheduler.h" |
| 10 | #include "core/hle/kernel/k_thread.h" | ||
| 10 | #include "core/hle/kernel/kernel.h" | 11 | #include "core/hle/kernel/kernel.h" |
| 11 | #include "core/hle/kernel/object.h" | 12 | #include "core/hle/kernel/object.h" |
| 12 | #include "core/hle/kernel/readable_event.h" | 13 | #include "core/hle/kernel/readable_event.h" |
| 13 | #include "core/hle/kernel/thread.h" | ||
| 14 | 14 | ||
| 15 | namespace Kernel { | 15 | namespace Kernel { |
| 16 | 16 | ||
diff --git a/src/core/hle/kernel/server_port.cpp b/src/core/hle/kernel/server_port.cpp index 82857f93b..fe7a483c4 100644 --- a/src/core/hle/kernel/server_port.cpp +++ b/src/core/hle/kernel/server_port.cpp | |||
| @@ -6,10 +6,10 @@ | |||
| 6 | #include "common/assert.h" | 6 | #include "common/assert.h" |
| 7 | #include "core/hle/kernel/client_port.h" | 7 | #include "core/hle/kernel/client_port.h" |
| 8 | #include "core/hle/kernel/errors.h" | 8 | #include "core/hle/kernel/errors.h" |
| 9 | #include "core/hle/kernel/k_thread.h" | ||
| 9 | #include "core/hle/kernel/object.h" | 10 | #include "core/hle/kernel/object.h" |
| 10 | #include "core/hle/kernel/server_port.h" | 11 | #include "core/hle/kernel/server_port.h" |
| 11 | #include "core/hle/kernel/server_session.h" | 12 | #include "core/hle/kernel/server_session.h" |
| 12 | #include "core/hle/kernel/thread.h" | ||
| 13 | 13 | ||
| 14 | namespace Kernel { | 14 | namespace Kernel { |
| 15 | 15 | ||
diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp index 4f2bb7822..280c9b5f6 100644 --- a/src/core/hle/kernel/server_session.cpp +++ b/src/core/hle/kernel/server_session.cpp | |||
| @@ -15,11 +15,11 @@ | |||
| 15 | #include "core/hle/kernel/handle_table.h" | 15 | #include "core/hle/kernel/handle_table.h" |
| 16 | #include "core/hle/kernel/hle_ipc.h" | 16 | #include "core/hle/kernel/hle_ipc.h" |
| 17 | #include "core/hle/kernel/k_scheduler.h" | 17 | #include "core/hle/kernel/k_scheduler.h" |
| 18 | #include "core/hle/kernel/k_thread.h" | ||
| 18 | #include "core/hle/kernel/kernel.h" | 19 | #include "core/hle/kernel/kernel.h" |
| 19 | #include "core/hle/kernel/process.h" | 20 | #include "core/hle/kernel/process.h" |
| 20 | #include "core/hle/kernel/server_session.h" | 21 | #include "core/hle/kernel/server_session.h" |
| 21 | #include "core/hle/kernel/session.h" | 22 | #include "core/hle/kernel/session.h" |
| 22 | #include "core/hle/kernel/thread.h" | ||
| 23 | #include "core/memory.h" | 23 | #include "core/memory.h" |
| 24 | 24 | ||
| 25 | namespace Kernel { | 25 | namespace Kernel { |
| @@ -116,7 +116,7 @@ ResultCode ServerSession::HandleDomainSyncRequest(Kernel::HLERequestContext& con | |||
| 116 | return RESULT_SUCCESS; | 116 | return RESULT_SUCCESS; |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | ResultCode ServerSession::QueueSyncRequest(std::shared_ptr<Thread> thread, | 119 | ResultCode ServerSession::QueueSyncRequest(std::shared_ptr<KThread> thread, |
| 120 | Core::Memory::Memory& memory) { | 120 | Core::Memory::Memory& memory) { |
| 121 | u32* cmd_buf{reinterpret_cast<u32*>(memory.GetPointer(thread->GetTLSAddress()))}; | 121 | u32* cmd_buf{reinterpret_cast<u32*>(memory.GetPointer(thread->GetTLSAddress()))}; |
| 122 | auto context = | 122 | auto context = |
| @@ -161,7 +161,7 @@ ResultCode ServerSession::CompleteSyncRequest(HLERequestContext& context) { | |||
| 161 | return result; | 161 | return result; |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | ResultCode ServerSession::HandleSyncRequest(std::shared_ptr<Thread> thread, | 164 | ResultCode ServerSession::HandleSyncRequest(std::shared_ptr<KThread> thread, |
| 165 | Core::Memory::Memory& memory, | 165 | Core::Memory::Memory& memory, |
| 166 | Core::Timing::CoreTiming& core_timing) { | 166 | Core::Timing::CoreTiming& core_timing) { |
| 167 | return QueueSyncRequest(std::move(thread), memory); | 167 | return QueueSyncRequest(std::move(thread), memory); |
diff --git a/src/core/hle/kernel/server_session.h b/src/core/hle/kernel/server_session.h index 9155cf7f5..d45cddec3 100644 --- a/src/core/hle/kernel/server_session.h +++ b/src/core/hle/kernel/server_session.h | |||
| @@ -29,7 +29,7 @@ class HLERequestContext; | |||
| 29 | class KernelCore; | 29 | class KernelCore; |
| 30 | class Session; | 30 | class Session; |
| 31 | class SessionRequestHandler; | 31 | class SessionRequestHandler; |
| 32 | class Thread; | 32 | class KThread; |
| 33 | 33 | ||
| 34 | /** | 34 | /** |
| 35 | * Kernel object representing the server endpoint of an IPC session. Sessions are the basic CTR-OS | 35 | * Kernel object representing the server endpoint of an IPC session. Sessions are the basic CTR-OS |
| @@ -95,7 +95,7 @@ public: | |||
| 95 | * | 95 | * |
| 96 | * @returns ResultCode from the operation. | 96 | * @returns ResultCode from the operation. |
| 97 | */ | 97 | */ |
| 98 | ResultCode HandleSyncRequest(std::shared_ptr<Thread> thread, Core::Memory::Memory& memory, | 98 | ResultCode HandleSyncRequest(std::shared_ptr<KThread> thread, Core::Memory::Memory& memory, |
| 99 | Core::Timing::CoreTiming& core_timing); | 99 | Core::Timing::CoreTiming& core_timing); |
| 100 | 100 | ||
| 101 | /// Called when a client disconnection occurs. | 101 | /// Called when a client disconnection occurs. |
| @@ -128,7 +128,7 @@ public: | |||
| 128 | 128 | ||
| 129 | private: | 129 | private: |
| 130 | /// Queues a sync request from the emulated application. | 130 | /// Queues a sync request from the emulated application. |
| 131 | ResultCode QueueSyncRequest(std::shared_ptr<Thread> thread, Core::Memory::Memory& memory); | 131 | ResultCode QueueSyncRequest(std::shared_ptr<KThread> thread, Core::Memory::Memory& memory); |
| 132 | 132 | ||
| 133 | /// Completes a sync request from the emulated application. | 133 | /// Completes a sync request from the emulated application. |
| 134 | ResultCode CompleteSyncRequest(HLERequestContext& context); | 134 | ResultCode CompleteSyncRequest(HLERequestContext& context); |
| @@ -149,12 +149,12 @@ private: | |||
| 149 | /// List of threads that are pending a response after a sync request. This list is processed in | 149 | /// List of threads that are pending a response after a sync request. This list is processed in |
| 150 | /// a LIFO manner, thus, the last request will be dispatched first. | 150 | /// a LIFO manner, thus, the last request will be dispatched first. |
| 151 | /// TODO(Subv): Verify if this is indeed processed in LIFO using a hardware test. | 151 | /// TODO(Subv): Verify if this is indeed processed in LIFO using a hardware test. |
| 152 | std::vector<std::shared_ptr<Thread>> pending_requesting_threads; | 152 | std::vector<std::shared_ptr<KThread>> pending_requesting_threads; |
| 153 | 153 | ||
| 154 | /// Thread whose request is currently being handled. A request is considered "handled" when a | 154 | /// Thread whose request is currently being handled. A request is considered "handled" when a |
| 155 | /// response is sent via svcReplyAndReceive. | 155 | /// response is sent via svcReplyAndReceive. |
| 156 | /// TODO(Subv): Find a better name for this. | 156 | /// TODO(Subv): Find a better name for this. |
| 157 | std::shared_ptr<Thread> currently_handling; | 157 | std::shared_ptr<KThread> currently_handling; |
| 158 | 158 | ||
| 159 | /// When set to True, converts the session to a domain at the end of the command | 159 | /// When set to True, converts the session to a domain at the end of the command |
| 160 | bool convert_to_domain{}; | 160 | bool convert_to_domain{}; |
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index cc8b661af..3609346d6 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -29,6 +29,7 @@ | |||
| 29 | #include "core/hle/kernel/k_scheduler.h" | 29 | #include "core/hle/kernel/k_scheduler.h" |
| 30 | #include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h" | 30 | #include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h" |
| 31 | #include "core/hle/kernel/k_synchronization_object.h" | 31 | #include "core/hle/kernel/k_synchronization_object.h" |
| 32 | #include "core/hle/kernel/k_thread.h" | ||
| 32 | #include "core/hle/kernel/kernel.h" | 33 | #include "core/hle/kernel/kernel.h" |
| 33 | #include "core/hle/kernel/memory/memory_block.h" | 34 | #include "core/hle/kernel/memory/memory_block.h" |
| 34 | #include "core/hle/kernel/memory/memory_layout.h" | 35 | #include "core/hle/kernel/memory/memory_layout.h" |
| @@ -42,7 +43,6 @@ | |||
| 42 | #include "core/hle/kernel/svc_results.h" | 43 | #include "core/hle/kernel/svc_results.h" |
| 43 | #include "core/hle/kernel/svc_types.h" | 44 | #include "core/hle/kernel/svc_types.h" |
| 44 | #include "core/hle/kernel/svc_wrap.h" | 45 | #include "core/hle/kernel/svc_wrap.h" |
| 45 | #include "core/hle/kernel/thread.h" | ||
| 46 | #include "core/hle/kernel/time_manager.h" | 46 | #include "core/hle/kernel/time_manager.h" |
| 47 | #include "core/hle/kernel/transfer_memory.h" | 47 | #include "core/hle/kernel/transfer_memory.h" |
| 48 | #include "core/hle/kernel/writable_event.h" | 48 | #include "core/hle/kernel/writable_event.h" |
| @@ -363,7 +363,7 @@ static ResultCode GetThreadId(Core::System& system, u64* thread_id, Handle threa | |||
| 363 | LOG_TRACE(Kernel_SVC, "called thread=0x{:08X}", thread_handle); | 363 | LOG_TRACE(Kernel_SVC, "called thread=0x{:08X}", thread_handle); |
| 364 | 364 | ||
| 365 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); | 365 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); |
| 366 | const std::shared_ptr<Thread> thread = handle_table.Get<Thread>(thread_handle); | 366 | const std::shared_ptr<KThread> thread = handle_table.Get<KThread>(thread_handle); |
| 367 | if (!thread) { | 367 | if (!thread) { |
| 368 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", thread_handle); | 368 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", thread_handle); |
| 369 | return ERR_INVALID_HANDLE; | 369 | return ERR_INVALID_HANDLE; |
| @@ -395,7 +395,7 @@ static ResultCode GetProcessId(Core::System& system, u64* process_id, Handle han | |||
| 395 | return RESULT_SUCCESS; | 395 | return RESULT_SUCCESS; |
| 396 | } | 396 | } |
| 397 | 397 | ||
| 398 | const std::shared_ptr<Thread> thread = handle_table.Get<Thread>(handle); | 398 | const std::shared_ptr<KThread> thread = handle_table.Get<KThread>(handle); |
| 399 | if (thread) { | 399 | if (thread) { |
| 400 | const Process* const owner_process = thread->GetOwnerProcess(); | 400 | const Process* const owner_process = thread->GetOwnerProcess(); |
| 401 | if (!owner_process) { | 401 | if (!owner_process) { |
| @@ -474,7 +474,7 @@ static ResultCode CancelSynchronization(Core::System& system, Handle thread_hand | |||
| 474 | LOG_TRACE(Kernel_SVC, "called thread=0x{:X}", thread_handle); | 474 | LOG_TRACE(Kernel_SVC, "called thread=0x{:X}", thread_handle); |
| 475 | 475 | ||
| 476 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); | 476 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); |
| 477 | std::shared_ptr<Thread> thread = handle_table.Get<Thread>(thread_handle); | 477 | std::shared_ptr<KThread> thread = handle_table.Get<KThread>(thread_handle); |
| 478 | if (!thread) { | 478 | if (!thread) { |
| 479 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, thread_handle=0x{:08X}", | 479 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, thread_handle=0x{:08X}", |
| 480 | thread_handle); | 480 | thread_handle); |
| @@ -872,7 +872,7 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha | |||
| 872 | return ERR_INVALID_COMBINATION; | 872 | return ERR_INVALID_COMBINATION; |
| 873 | } | 873 | } |
| 874 | 874 | ||
| 875 | const auto thread = system.Kernel().CurrentProcess()->GetHandleTable().Get<Thread>( | 875 | const auto thread = system.Kernel().CurrentProcess()->GetHandleTable().Get<KThread>( |
| 876 | static_cast<Handle>(handle)); | 876 | static_cast<Handle>(handle)); |
| 877 | if (!thread) { | 877 | if (!thread) { |
| 878 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", | 878 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", |
| @@ -1033,7 +1033,7 @@ static ResultCode SetThreadActivity(Core::System& system, Handle handle, u32 act | |||
| 1033 | } | 1033 | } |
| 1034 | 1034 | ||
| 1035 | const auto* current_process = system.Kernel().CurrentProcess(); | 1035 | const auto* current_process = system.Kernel().CurrentProcess(); |
| 1036 | const std::shared_ptr<Thread> thread = current_process->GetHandleTable().Get<Thread>(handle); | 1036 | const std::shared_ptr<KThread> thread = current_process->GetHandleTable().Get<KThread>(handle); |
| 1037 | if (!thread) { | 1037 | if (!thread) { |
| 1038 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", handle); | 1038 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", handle); |
| 1039 | return ERR_INVALID_HANDLE; | 1039 | return ERR_INVALID_HANDLE; |
| @@ -1066,7 +1066,7 @@ static ResultCode GetThreadContext(Core::System& system, VAddr thread_context, H | |||
| 1066 | LOG_DEBUG(Kernel_SVC, "called, context=0x{:08X}, thread=0x{:X}", thread_context, handle); | 1066 | LOG_DEBUG(Kernel_SVC, "called, context=0x{:08X}, thread=0x{:X}", thread_context, handle); |
| 1067 | 1067 | ||
| 1068 | const auto* current_process = system.Kernel().CurrentProcess(); | 1068 | const auto* current_process = system.Kernel().CurrentProcess(); |
| 1069 | const std::shared_ptr<Thread> thread = current_process->GetHandleTable().Get<Thread>(handle); | 1069 | const std::shared_ptr<KThread> thread = current_process->GetHandleTable().Get<KThread>(handle); |
| 1070 | if (!thread) { | 1070 | if (!thread) { |
| 1071 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", handle); | 1071 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", handle); |
| 1072 | return ERR_INVALID_HANDLE; | 1072 | return ERR_INVALID_HANDLE; |
| @@ -1111,7 +1111,7 @@ static ResultCode GetThreadPriority(Core::System& system, u32* priority, Handle | |||
| 1111 | LOG_TRACE(Kernel_SVC, "called"); | 1111 | LOG_TRACE(Kernel_SVC, "called"); |
| 1112 | 1112 | ||
| 1113 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); | 1113 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); |
| 1114 | const std::shared_ptr<Thread> thread = handle_table.Get<Thread>(handle); | 1114 | const std::shared_ptr<KThread> thread = handle_table.Get<KThread>(handle); |
| 1115 | if (!thread) { | 1115 | if (!thread) { |
| 1116 | *priority = 0; | 1116 | *priority = 0; |
| 1117 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", handle); | 1117 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", handle); |
| @@ -1140,7 +1140,7 @@ static ResultCode SetThreadPriority(Core::System& system, Handle handle, u32 pri | |||
| 1140 | 1140 | ||
| 1141 | const auto* const current_process = system.Kernel().CurrentProcess(); | 1141 | const auto* const current_process = system.Kernel().CurrentProcess(); |
| 1142 | 1142 | ||
| 1143 | std::shared_ptr<Thread> thread = current_process->GetHandleTable().Get<Thread>(handle); | 1143 | std::shared_ptr<KThread> thread = current_process->GetHandleTable().Get<KThread>(handle); |
| 1144 | if (!thread) { | 1144 | if (!thread) { |
| 1145 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", handle); | 1145 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", handle); |
| 1146 | return ERR_INVALID_HANDLE; | 1146 | return ERR_INVALID_HANDLE; |
| @@ -1489,9 +1489,9 @@ static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr e | |||
| 1489 | ASSERT(kernel.CurrentProcess()->GetResourceLimit()->Reserve(ResourceType::Threads, 1)); | 1489 | ASSERT(kernel.CurrentProcess()->GetResourceLimit()->Reserve(ResourceType::Threads, 1)); |
| 1490 | 1490 | ||
| 1491 | ThreadType type = THREADTYPE_USER; | 1491 | ThreadType type = THREADTYPE_USER; |
| 1492 | CASCADE_RESULT(std::shared_ptr<Thread> thread, | 1492 | CASCADE_RESULT(std::shared_ptr<KThread> thread, |
| 1493 | Thread::Create(system, type, "", entry_point, priority, arg, processor_id, | 1493 | KThread::Create(system, type, "", entry_point, priority, arg, processor_id, |
| 1494 | stack_top, current_process)); | 1494 | stack_top, current_process)); |
| 1495 | 1495 | ||
| 1496 | const auto new_thread_handle = current_process->GetHandleTable().Create(thread); | 1496 | const auto new_thread_handle = current_process->GetHandleTable().Create(thread); |
| 1497 | if (new_thread_handle.Failed()) { | 1497 | if (new_thread_handle.Failed()) { |
| @@ -1518,7 +1518,7 @@ static ResultCode StartThread(Core::System& system, Handle thread_handle) { | |||
| 1518 | LOG_DEBUG(Kernel_SVC, "called thread=0x{:08X}", thread_handle); | 1518 | LOG_DEBUG(Kernel_SVC, "called thread=0x{:08X}", thread_handle); |
| 1519 | 1519 | ||
| 1520 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); | 1520 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); |
| 1521 | const std::shared_ptr<Thread> thread = handle_table.Get<Thread>(thread_handle); | 1521 | const std::shared_ptr<KThread> thread = handle_table.Get<KThread>(thread_handle); |
| 1522 | if (!thread) { | 1522 | if (!thread) { |
| 1523 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, thread_handle=0x{:08X}", | 1523 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, thread_handle=0x{:08X}", |
| 1524 | thread_handle); | 1524 | thread_handle); |
| @@ -1844,7 +1844,7 @@ static ResultCode GetThreadCoreMask(Core::System& system, Handle thread_handle, | |||
| 1844 | LOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle); | 1844 | LOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle); |
| 1845 | 1845 | ||
| 1846 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); | 1846 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); |
| 1847 | const std::shared_ptr<Thread> thread = handle_table.Get<Thread>(thread_handle); | 1847 | const std::shared_ptr<KThread> thread = handle_table.Get<KThread>(thread_handle); |
| 1848 | if (!thread) { | 1848 | if (!thread) { |
| 1849 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, thread_handle=0x{:08X}", | 1849 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, thread_handle=0x{:08X}", |
| 1850 | thread_handle); | 1850 | thread_handle); |
| @@ -1914,7 +1914,7 @@ static ResultCode SetThreadCoreMask(Core::System& system, Handle thread_handle, | |||
| 1914 | } | 1914 | } |
| 1915 | 1915 | ||
| 1916 | const auto& handle_table = current_process->GetHandleTable(); | 1916 | const auto& handle_table = current_process->GetHandleTable(); |
| 1917 | const std::shared_ptr<Thread> thread = handle_table.Get<Thread>(thread_handle); | 1917 | const std::shared_ptr<KThread> thread = handle_table.Get<KThread>(thread_handle); |
| 1918 | if (!thread) { | 1918 | if (!thread) { |
| 1919 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, thread_handle=0x{:08X}", | 1919 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, thread_handle=0x{:08X}", |
| 1920 | thread_handle); | 1920 | thread_handle); |
diff --git a/src/core/hle/kernel/time_manager.cpp b/src/core/hle/kernel/time_manager.cpp index 832edd629..aaeef3033 100644 --- a/src/core/hle/kernel/time_manager.cpp +++ b/src/core/hle/kernel/time_manager.cpp | |||
| @@ -8,8 +8,8 @@ | |||
| 8 | #include "core/core_timing_util.h" | 8 | #include "core/core_timing_util.h" |
| 9 | #include "core/hle/kernel/handle_table.h" | 9 | #include "core/hle/kernel/handle_table.h" |
| 10 | #include "core/hle/kernel/k_scheduler.h" | 10 | #include "core/hle/kernel/k_scheduler.h" |
| 11 | #include "core/hle/kernel/k_thread.h" | ||
| 11 | #include "core/hle/kernel/kernel.h" | 12 | #include "core/hle/kernel/kernel.h" |
| 12 | #include "core/hle/kernel/thread.h" | ||
| 13 | #include "core/hle/kernel/time_manager.h" | 13 | #include "core/hle/kernel/time_manager.h" |
| 14 | 14 | ||
| 15 | namespace Kernel { | 15 | namespace Kernel { |
| @@ -18,7 +18,7 @@ TimeManager::TimeManager(Core::System& system_) : system{system_} { | |||
| 18 | time_manager_event_type = Core::Timing::CreateEvent( | 18 | time_manager_event_type = Core::Timing::CreateEvent( |
| 19 | "Kernel::TimeManagerCallback", | 19 | "Kernel::TimeManagerCallback", |
| 20 | [this](std::uintptr_t thread_handle, std::chrono::nanoseconds) { | 20 | [this](std::uintptr_t thread_handle, std::chrono::nanoseconds) { |
| 21 | std::shared_ptr<Thread> thread; | 21 | std::shared_ptr<KThread> thread; |
| 22 | { | 22 | { |
| 23 | std::lock_guard lock{mutex}; | 23 | std::lock_guard lock{mutex}; |
| 24 | const auto proper_handle = static_cast<Handle>(thread_handle); | 24 | const auto proper_handle = static_cast<Handle>(thread_handle); |
| @@ -35,7 +35,7 @@ TimeManager::TimeManager(Core::System& system_) : system{system_} { | |||
| 35 | }); | 35 | }); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | void TimeManager::ScheduleTimeEvent(Handle& event_handle, Thread* timetask, s64 nanoseconds) { | 38 | void TimeManager::ScheduleTimeEvent(Handle& event_handle, KThread* timetask, s64 nanoseconds) { |
| 39 | std::lock_guard lock{mutex}; | 39 | std::lock_guard lock{mutex}; |
| 40 | event_handle = timetask->GetGlobalHandle(); | 40 | event_handle = timetask->GetGlobalHandle(); |
| 41 | if (nanoseconds > 0) { | 41 | if (nanoseconds > 0) { |
| @@ -58,7 +58,7 @@ void TimeManager::UnscheduleTimeEvent(Handle event_handle) { | |||
| 58 | cancelled_events[event_handle] = true; | 58 | cancelled_events[event_handle] = true; |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | void TimeManager::CancelTimeEvent(Thread* time_task) { | 61 | void TimeManager::CancelTimeEvent(KThread* time_task) { |
| 62 | std::lock_guard lock{mutex}; | 62 | std::lock_guard lock{mutex}; |
| 63 | const Handle event_handle = time_task->GetGlobalHandle(); | 63 | const Handle event_handle = time_task->GetGlobalHandle(); |
| 64 | UnscheduleTimeEvent(event_handle); | 64 | UnscheduleTimeEvent(event_handle); |
diff --git a/src/core/hle/kernel/time_manager.h b/src/core/hle/kernel/time_manager.h index f39df39a0..7cc702bec 100644 --- a/src/core/hle/kernel/time_manager.h +++ b/src/core/hle/kernel/time_manager.h | |||
| @@ -20,7 +20,7 @@ struct EventType; | |||
| 20 | 20 | ||
| 21 | namespace Kernel { | 21 | namespace Kernel { |
| 22 | 22 | ||
| 23 | class Thread; | 23 | class KThread; |
| 24 | 24 | ||
| 25 | /** | 25 | /** |
| 26 | * The `TimeManager` takes care of scheduling time events on threads and executes their TimeUp | 26 | * The `TimeManager` takes care of scheduling time events on threads and executes their TimeUp |
| @@ -32,12 +32,12 @@ public: | |||
| 32 | 32 | ||
| 33 | /// Schedule a time event on `timetask` thread that will expire in 'nanoseconds' | 33 | /// Schedule a time event on `timetask` thread that will expire in 'nanoseconds' |
| 34 | /// returns a non-invalid handle in `event_handle` if correctly scheduled | 34 | /// returns a non-invalid handle in `event_handle` if correctly scheduled |
| 35 | void ScheduleTimeEvent(Handle& event_handle, Thread* timetask, s64 nanoseconds); | 35 | void ScheduleTimeEvent(Handle& event_handle, KThread* timetask, s64 nanoseconds); |
| 36 | 36 | ||
| 37 | /// Unschedule an existing time event | 37 | /// Unschedule an existing time event |
| 38 | void UnscheduleTimeEvent(Handle event_handle); | 38 | void UnscheduleTimeEvent(Handle event_handle); |
| 39 | 39 | ||
| 40 | void CancelTimeEvent(Thread* time_task); | 40 | void CancelTimeEvent(KThread* time_task); |
| 41 | 41 | ||
| 42 | private: | 42 | private: |
| 43 | Core::System& system; | 43 | Core::System& system; |
diff --git a/src/core/hle/kernel/writable_event.cpp b/src/core/hle/kernel/writable_event.cpp index fc2f7c424..dbe34472b 100644 --- a/src/core/hle/kernel/writable_event.cpp +++ b/src/core/hle/kernel/writable_event.cpp | |||
| @@ -4,10 +4,10 @@ | |||
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include "common/assert.h" | 6 | #include "common/assert.h" |
| 7 | #include "core/hle/kernel/k_thread.h" | ||
| 7 | #include "core/hle/kernel/kernel.h" | 8 | #include "core/hle/kernel/kernel.h" |
| 8 | #include "core/hle/kernel/object.h" | 9 | #include "core/hle/kernel/object.h" |
| 9 | #include "core/hle/kernel/readable_event.h" | 10 | #include "core/hle/kernel/readable_event.h" |
| 10 | #include "core/hle/kernel/thread.h" | ||
| 11 | #include "core/hle/kernel/writable_event.h" | 11 | #include "core/hle/kernel/writable_event.h" |
| 12 | 12 | ||
| 13 | namespace Kernel { | 13 | namespace Kernel { |
diff --git a/src/core/hle/service/nfp/nfp.cpp b/src/core/hle/service/nfp/nfp.cpp index 641bcadea..a515fdc60 100644 --- a/src/core/hle/service/nfp/nfp.cpp +++ b/src/core/hle/service/nfp/nfp.cpp | |||
| @@ -8,9 +8,9 @@ | |||
| 8 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 9 | #include "core/core.h" | 9 | #include "core/core.h" |
| 10 | #include "core/hle/ipc_helpers.h" | 10 | #include "core/hle/ipc_helpers.h" |
| 11 | #include "core/hle/kernel/k_thread.h" | ||
| 11 | #include "core/hle/kernel/kernel.h" | 12 | #include "core/hle/kernel/kernel.h" |
| 12 | #include "core/hle/kernel/readable_event.h" | 13 | #include "core/hle/kernel/readable_event.h" |
| 13 | #include "core/hle/kernel/thread.h" | ||
| 14 | #include "core/hle/kernel/writable_event.h" | 14 | #include "core/hle/kernel/writable_event.h" |
| 15 | #include "core/hle/lock.h" | 15 | #include "core/hle/lock.h" |
| 16 | #include "core/hle/service/nfp/nfp.h" | 16 | #include "core/hle/service/nfp/nfp.h" |
diff --git a/src/core/hle/service/nvdrv/interface.cpp b/src/core/hle/service/nvdrv/interface.cpp index cc23b001c..1328b64d0 100644 --- a/src/core/hle/service/nvdrv/interface.cpp +++ b/src/core/hle/service/nvdrv/interface.cpp | |||
| @@ -6,9 +6,9 @@ | |||
| 6 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 7 | #include "core/core.h" | 7 | #include "core/core.h" |
| 8 | #include "core/hle/ipc_helpers.h" | 8 | #include "core/hle/ipc_helpers.h" |
| 9 | #include "core/hle/kernel/k_thread.h" | ||
| 9 | #include "core/hle/kernel/kernel.h" | 10 | #include "core/hle/kernel/kernel.h" |
| 10 | #include "core/hle/kernel/readable_event.h" | 11 | #include "core/hle/kernel/readable_event.h" |
| 11 | #include "core/hle/kernel/thread.h" | ||
| 12 | #include "core/hle/kernel/writable_event.h" | 12 | #include "core/hle/kernel/writable_event.h" |
| 13 | #include "core/hle/service/nvdrv/interface.h" | 13 | #include "core/hle/service/nvdrv/interface.h" |
| 14 | #include "core/hle/service/nvdrv/nvdata.h" | 14 | #include "core/hle/service/nvdrv/nvdata.h" |
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index ff2a5b1db..1da56bc27 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp | |||
| @@ -11,10 +11,10 @@ | |||
| 11 | #include "core/hle/ipc.h" | 11 | #include "core/hle/ipc.h" |
| 12 | #include "core/hle/ipc_helpers.h" | 12 | #include "core/hle/ipc_helpers.h" |
| 13 | #include "core/hle/kernel/client_port.h" | 13 | #include "core/hle/kernel/client_port.h" |
| 14 | #include "core/hle/kernel/k_thread.h" | ||
| 14 | #include "core/hle/kernel/kernel.h" | 15 | #include "core/hle/kernel/kernel.h" |
| 15 | #include "core/hle/kernel/process.h" | 16 | #include "core/hle/kernel/process.h" |
| 16 | #include "core/hle/kernel/server_port.h" | 17 | #include "core/hle/kernel/server_port.h" |
| 17 | #include "core/hle/kernel/thread.h" | ||
| 18 | #include "core/hle/service/acc/acc.h" | 18 | #include "core/hle/service/acc/acc.h" |
| 19 | #include "core/hle/service/am/am.h" | 19 | #include "core/hle/service/am/am.h" |
| 20 | #include "core/hle/service/aoc/aoc_u.h" | 20 | #include "core/hle/service/aoc/aoc_u.h" |
diff --git a/src/core/hle/service/sockets/bsd.cpp b/src/core/hle/service/sockets/bsd.cpp index d85df6af1..22f540914 100644 --- a/src/core/hle/service/sockets/bsd.cpp +++ b/src/core/hle/service/sockets/bsd.cpp | |||
| @@ -13,7 +13,7 @@ | |||
| 13 | #include "common/microprofile.h" | 13 | #include "common/microprofile.h" |
| 14 | #include "common/thread.h" | 14 | #include "common/thread.h" |
| 15 | #include "core/hle/ipc_helpers.h" | 15 | #include "core/hle/ipc_helpers.h" |
| 16 | #include "core/hle/kernel/thread.h" | 16 | #include "core/hle/kernel/k_thread.h" |
| 17 | #include "core/hle/service/sockets/bsd.h" | 17 | #include "core/hle/service/sockets/bsd.h" |
| 18 | #include "core/hle/service/sockets/sockets_translate.h" | 18 | #include "core/hle/service/sockets/sockets_translate.h" |
| 19 | #include "core/network/network.h" | 19 | #include "core/network/network.h" |
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index abc753d5d..18629dd7e 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp | |||
| @@ -121,7 +121,7 @@ private: | |||
| 121 | }; | 121 | }; |
| 122 | 122 | ||
| 123 | ResultCode Module::Interface::GetClockSnapshotFromSystemClockContextInternal( | 123 | ResultCode Module::Interface::GetClockSnapshotFromSystemClockContextInternal( |
| 124 | Kernel::Thread* thread, Clock::SystemClockContext user_context, | 124 | Kernel::KThread* thread, Clock::SystemClockContext user_context, |
| 125 | Clock::SystemClockContext network_context, u8 type, Clock::ClockSnapshot& clock_snapshot) { | 125 | Clock::SystemClockContext network_context, u8 type, Clock::ClockSnapshot& clock_snapshot) { |
| 126 | 126 | ||
| 127 | auto& time_manager{system.GetTimeManager()}; | 127 | auto& time_manager{system.GetTimeManager()}; |
diff --git a/src/core/hle/service/time/time.h b/src/core/hle/service/time/time.h index 975a8ae5b..4154c7ee9 100644 --- a/src/core/hle/service/time/time.h +++ b/src/core/hle/service/time/time.h | |||
| @@ -39,7 +39,7 @@ public: | |||
| 39 | 39 | ||
| 40 | private: | 40 | private: |
| 41 | ResultCode GetClockSnapshotFromSystemClockContextInternal( | 41 | ResultCode GetClockSnapshotFromSystemClockContextInternal( |
| 42 | Kernel::Thread* thread, Clock::SystemClockContext user_context, | 42 | Kernel::KThread* thread, Clock::SystemClockContext user_context, |
| 43 | Clock::SystemClockContext network_context, u8 type, | 43 | Clock::SystemClockContext network_context, u8 type, |
| 44 | Clock::ClockSnapshot& cloc_snapshot); | 44 | Clock::ClockSnapshot& cloc_snapshot); |
| 45 | 45 | ||
diff --git a/src/core/hle/service/time/time_sharedmemory.h b/src/core/hle/service/time/time_sharedmemory.h index 5976b2046..e0c3e63da 100644 --- a/src/core/hle/service/time/time_sharedmemory.h +++ b/src/core/hle/service/time/time_sharedmemory.h | |||
| @@ -6,8 +6,8 @@ | |||
| 6 | 6 | ||
| 7 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 8 | #include "common/uuid.h" | 8 | #include "common/uuid.h" |
| 9 | #include "core/hle/kernel/k_thread.h" | ||
| 9 | #include "core/hle/kernel/shared_memory.h" | 10 | #include "core/hle/kernel/shared_memory.h" |
| 10 | #include "core/hle/kernel/thread.h" | ||
| 11 | #include "core/hle/service/time/clock_types.h" | 11 | #include "core/hle/service/time/clock_types.h" |
| 12 | 12 | ||
| 13 | namespace Service::Time { | 13 | namespace Service::Time { |
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 968cd16b6..f3de2c428 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp | |||
| @@ -18,8 +18,8 @@ | |||
| 18 | #include "common/swap.h" | 18 | #include "common/swap.h" |
| 19 | #include "core/core_timing.h" | 19 | #include "core/core_timing.h" |
| 20 | #include "core/hle/ipc_helpers.h" | 20 | #include "core/hle/ipc_helpers.h" |
| 21 | #include "core/hle/kernel/k_thread.h" | ||
| 21 | #include "core/hle/kernel/readable_event.h" | 22 | #include "core/hle/kernel/readable_event.h" |
| 22 | #include "core/hle/kernel/thread.h" | ||
| 23 | #include "core/hle/kernel/writable_event.h" | 23 | #include "core/hle/kernel/writable_event.h" |
| 24 | #include "core/hle/service/nvdrv/nvdata.h" | 24 | #include "core/hle/service/nvdrv/nvdata.h" |
| 25 | #include "core/hle/service/nvdrv/nvdrv.h" | 25 | #include "core/hle/service/nvdrv/nvdrv.h" |
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp index ccf8cc153..4f55314c7 100644 --- a/src/core/loader/nro.cpp +++ b/src/core/loader/nro.cpp | |||
| @@ -15,9 +15,9 @@ | |||
| 15 | #include "core/file_sys/romfs_factory.h" | 15 | #include "core/file_sys/romfs_factory.h" |
| 16 | #include "core/file_sys/vfs_offset.h" | 16 | #include "core/file_sys/vfs_offset.h" |
| 17 | #include "core/hle/kernel/code_set.h" | 17 | #include "core/hle/kernel/code_set.h" |
| 18 | #include "core/hle/kernel/k_thread.h" | ||
| 18 | #include "core/hle/kernel/memory/page_table.h" | 19 | #include "core/hle/kernel/memory/page_table.h" |
| 19 | #include "core/hle/kernel/process.h" | 20 | #include "core/hle/kernel/process.h" |
| 20 | #include "core/hle/kernel/thread.h" | ||
| 21 | #include "core/hle/service/filesystem/filesystem.h" | 21 | #include "core/hle/service/filesystem/filesystem.h" |
| 22 | #include "core/loader/nro.h" | 22 | #include "core/loader/nro.h" |
| 23 | #include "core/loader/nso.h" | 23 | #include "core/loader/nso.h" |
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index 95b6f339a..50e6cd080 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp | |||
| @@ -15,9 +15,9 @@ | |||
| 15 | #include "core/core.h" | 15 | #include "core/core.h" |
| 16 | #include "core/file_sys/patch_manager.h" | 16 | #include "core/file_sys/patch_manager.h" |
| 17 | #include "core/hle/kernel/code_set.h" | 17 | #include "core/hle/kernel/code_set.h" |
| 18 | #include "core/hle/kernel/k_thread.h" | ||
| 18 | #include "core/hle/kernel/memory/page_table.h" | 19 | #include "core/hle/kernel/memory/page_table.h" |
| 19 | #include "core/hle/kernel/process.h" | 20 | #include "core/hle/kernel/process.h" |
| 20 | #include "core/hle/kernel/thread.h" | ||
| 21 | #include "core/loader/nso.h" | 21 | #include "core/loader/nso.h" |
| 22 | #include "core/memory.h" | 22 | #include "core/memory.h" |
| 23 | #include "core/settings.h" | 23 | #include "core/settings.h" |
diff --git a/src/yuzu/debugger/wait_tree.cpp b/src/yuzu/debugger/wait_tree.cpp index a93b5d3c2..55a3f7d60 100644 --- a/src/yuzu/debugger/wait_tree.cpp +++ b/src/yuzu/debugger/wait_tree.cpp | |||
| @@ -15,10 +15,10 @@ | |||
| 15 | #include "core/hle/kernel/handle_table.h" | 15 | #include "core/hle/kernel/handle_table.h" |
| 16 | #include "core/hle/kernel/k_scheduler.h" | 16 | #include "core/hle/kernel/k_scheduler.h" |
| 17 | #include "core/hle/kernel/k_synchronization_object.h" | 17 | #include "core/hle/kernel/k_synchronization_object.h" |
| 18 | #include "core/hle/kernel/k_thread.h" | ||
| 18 | #include "core/hle/kernel/process.h" | 19 | #include "core/hle/kernel/process.h" |
| 19 | #include "core/hle/kernel/readable_event.h" | 20 | #include "core/hle/kernel/readable_event.h" |
| 20 | #include "core/hle/kernel/svc_common.h" | 21 | #include "core/hle/kernel/svc_common.h" |
| 21 | #include "core/hle/kernel/thread.h" | ||
| 22 | #include "core/memory.h" | 22 | #include "core/memory.h" |
| 23 | 23 | ||
| 24 | namespace { | 24 | namespace { |
| @@ -90,7 +90,7 @@ std::size_t WaitTreeItem::Row() const { | |||
| 90 | std::vector<std::unique_ptr<WaitTreeThread>> WaitTreeItem::MakeThreadItemList() { | 90 | std::vector<std::unique_ptr<WaitTreeThread>> WaitTreeItem::MakeThreadItemList() { |
| 91 | std::vector<std::unique_ptr<WaitTreeThread>> item_list; | 91 | std::vector<std::unique_ptr<WaitTreeThread>> item_list; |
| 92 | std::size_t row = 0; | 92 | std::size_t row = 0; |
| 93 | auto add_threads = [&](const std::vector<std::shared_ptr<Kernel::Thread>>& threads) { | 93 | auto add_threads = [&](const std::vector<std::shared_ptr<Kernel::KThread>>& threads) { |
| 94 | for (std::size_t i = 0; i < threads.size(); ++i) { | 94 | for (std::size_t i = 0; i < threads.size(); ++i) { |
| 95 | if (!threads[i]->IsHLEThread()) { | 95 | if (!threads[i]->IsHLEThread()) { |
| 96 | item_list.push_back(std::make_unique<WaitTreeThread>(*threads[i])); | 96 | item_list.push_back(std::make_unique<WaitTreeThread>(*threads[i])); |
| @@ -117,7 +117,7 @@ WaitTreeMutexInfo::WaitTreeMutexInfo(VAddr mutex_address, const Kernel::HandleTa | |||
| 117 | : mutex_address(mutex_address) { | 117 | : mutex_address(mutex_address) { |
| 118 | mutex_value = Core::System::GetInstance().Memory().Read32(mutex_address); | 118 | mutex_value = Core::System::GetInstance().Memory().Read32(mutex_address); |
| 119 | owner_handle = static_cast<Kernel::Handle>(mutex_value & Kernel::Svc::HandleWaitMask); | 119 | owner_handle = static_cast<Kernel::Handle>(mutex_value & Kernel::Svc::HandleWaitMask); |
| 120 | owner = handle_table.Get<Kernel::Thread>(owner_handle); | 120 | owner = handle_table.Get<Kernel::KThread>(owner_handle); |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | WaitTreeMutexInfo::~WaitTreeMutexInfo() = default; | 123 | WaitTreeMutexInfo::~WaitTreeMutexInfo() = default; |
| @@ -139,7 +139,7 @@ std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeMutexInfo::GetChildren() cons | |||
| 139 | return list; | 139 | return list; |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | WaitTreeCallstack::WaitTreeCallstack(const Kernel::Thread& thread) : thread(thread) {} | 142 | WaitTreeCallstack::WaitTreeCallstack(const Kernel::KThread& thread) : thread(thread) {} |
| 143 | WaitTreeCallstack::~WaitTreeCallstack() = default; | 143 | WaitTreeCallstack::~WaitTreeCallstack() = default; |
| 144 | 144 | ||
| 145 | QString WaitTreeCallstack::GetText() const { | 145 | QString WaitTreeCallstack::GetText() const { |
| @@ -194,7 +194,7 @@ std::unique_ptr<WaitTreeSynchronizationObject> WaitTreeSynchronizationObject::ma | |||
| 194 | case Kernel::HandleType::ReadableEvent: | 194 | case Kernel::HandleType::ReadableEvent: |
| 195 | return std::make_unique<WaitTreeEvent>(static_cast<const Kernel::ReadableEvent&>(object)); | 195 | return std::make_unique<WaitTreeEvent>(static_cast<const Kernel::ReadableEvent&>(object)); |
| 196 | case Kernel::HandleType::Thread: | 196 | case Kernel::HandleType::Thread: |
| 197 | return std::make_unique<WaitTreeThread>(static_cast<const Kernel::Thread&>(object)); | 197 | return std::make_unique<WaitTreeThread>(static_cast<const Kernel::KThread&>(object)); |
| 198 | default: | 198 | default: |
| 199 | return std::make_unique<WaitTreeSynchronizationObject>(object); | 199 | return std::make_unique<WaitTreeSynchronizationObject>(object); |
| 200 | } | 200 | } |
| @@ -231,12 +231,12 @@ std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeObjectList::GetChildren() con | |||
| 231 | return list; | 231 | return list; |
| 232 | } | 232 | } |
| 233 | 233 | ||
| 234 | WaitTreeThread::WaitTreeThread(const Kernel::Thread& thread) | 234 | WaitTreeThread::WaitTreeThread(const Kernel::KThread& thread) |
| 235 | : WaitTreeSynchronizationObject(thread) {} | 235 | : WaitTreeSynchronizationObject(thread) {} |
| 236 | WaitTreeThread::~WaitTreeThread() = default; | 236 | WaitTreeThread::~WaitTreeThread() = default; |
| 237 | 237 | ||
| 238 | QString WaitTreeThread::GetText() const { | 238 | QString WaitTreeThread::GetText() const { |
| 239 | const auto& thread = static_cast<const Kernel::Thread&>(object); | 239 | const auto& thread = static_cast<const Kernel::KThread&>(object); |
| 240 | QString status; | 240 | QString status; |
| 241 | switch (thread.GetState()) { | 241 | switch (thread.GetState()) { |
| 242 | case Kernel::ThreadState::Runnable: | 242 | case Kernel::ThreadState::Runnable: |
| @@ -297,7 +297,7 @@ QString WaitTreeThread::GetText() const { | |||
| 297 | QColor WaitTreeThread::GetColor() const { | 297 | QColor WaitTreeThread::GetColor() const { |
| 298 | const std::size_t color_index = IsDarkTheme() ? 1 : 0; | 298 | const std::size_t color_index = IsDarkTheme() ? 1 : 0; |
| 299 | 299 | ||
| 300 | const auto& thread = static_cast<const Kernel::Thread&>(object); | 300 | const auto& thread = static_cast<const Kernel::KThread&>(object); |
| 301 | switch (thread.GetState()) { | 301 | switch (thread.GetState()) { |
| 302 | case Kernel::ThreadState::Runnable: | 302 | case Kernel::ThreadState::Runnable: |
| 303 | if (!thread.IsPaused()) { | 303 | if (!thread.IsPaused()) { |
| @@ -336,7 +336,7 @@ QColor WaitTreeThread::GetColor() const { | |||
| 336 | std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeThread::GetChildren() const { | 336 | std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeThread::GetChildren() const { |
| 337 | std::vector<std::unique_ptr<WaitTreeItem>> list(WaitTreeSynchronizationObject::GetChildren()); | 337 | std::vector<std::unique_ptr<WaitTreeItem>> list(WaitTreeSynchronizationObject::GetChildren()); |
| 338 | 338 | ||
| 339 | const auto& thread = static_cast<const Kernel::Thread&>(object); | 339 | const auto& thread = static_cast<const Kernel::KThread&>(object); |
| 340 | 340 | ||
| 341 | QString processor; | 341 | QString processor; |
| 342 | switch (thread.GetProcessorID()) { | 342 | switch (thread.GetProcessorID()) { |
| @@ -390,7 +390,7 @@ WaitTreeEvent::WaitTreeEvent(const Kernel::ReadableEvent& object) | |||
| 390 | : WaitTreeSynchronizationObject(object) {} | 390 | : WaitTreeSynchronizationObject(object) {} |
| 391 | WaitTreeEvent::~WaitTreeEvent() = default; | 391 | WaitTreeEvent::~WaitTreeEvent() = default; |
| 392 | 392 | ||
| 393 | WaitTreeThreadList::WaitTreeThreadList(const std::vector<Kernel::Thread*>& list) | 393 | WaitTreeThreadList::WaitTreeThreadList(const std::vector<Kernel::KThread*>& list) |
| 394 | : thread_list(list) {} | 394 | : thread_list(list) {} |
| 395 | WaitTreeThreadList::~WaitTreeThreadList() = default; | 395 | WaitTreeThreadList::~WaitTreeThreadList() = default; |
| 396 | 396 | ||
diff --git a/src/yuzu/debugger/wait_tree.h b/src/yuzu/debugger/wait_tree.h index cf96911ea..b202c5567 100644 --- a/src/yuzu/debugger/wait_tree.h +++ b/src/yuzu/debugger/wait_tree.h | |||
| @@ -19,8 +19,8 @@ class EmuThread; | |||
| 19 | namespace Kernel { | 19 | namespace Kernel { |
| 20 | class HandleTable; | 20 | class HandleTable; |
| 21 | class KSynchronizationObject; | 21 | class KSynchronizationObject; |
| 22 | class KThread; | ||
| 22 | class ReadableEvent; | 23 | class ReadableEvent; |
| 23 | class Thread; | ||
| 24 | } // namespace Kernel | 24 | } // namespace Kernel |
| 25 | 25 | ||
| 26 | class WaitTreeThread; | 26 | class WaitTreeThread; |
| @@ -83,20 +83,20 @@ private: | |||
| 83 | VAddr mutex_address; | 83 | VAddr mutex_address; |
| 84 | u32 mutex_value; | 84 | u32 mutex_value; |
| 85 | Kernel::Handle owner_handle; | 85 | Kernel::Handle owner_handle; |
| 86 | std::shared_ptr<Kernel::Thread> owner; | 86 | std::shared_ptr<Kernel::KThread> owner; |
| 87 | }; | 87 | }; |
| 88 | 88 | ||
| 89 | class WaitTreeCallstack : public WaitTreeExpandableItem { | 89 | class WaitTreeCallstack : public WaitTreeExpandableItem { |
| 90 | Q_OBJECT | 90 | Q_OBJECT |
| 91 | public: | 91 | public: |
| 92 | explicit WaitTreeCallstack(const Kernel::Thread& thread); | 92 | explicit WaitTreeCallstack(const Kernel::KThread& thread); |
| 93 | ~WaitTreeCallstack() override; | 93 | ~WaitTreeCallstack() override; |
| 94 | 94 | ||
| 95 | QString GetText() const override; | 95 | QString GetText() const override; |
| 96 | std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; | 96 | std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; |
| 97 | 97 | ||
| 98 | private: | 98 | private: |
| 99 | const Kernel::Thread& thread; | 99 | const Kernel::KThread& thread; |
| 100 | }; | 100 | }; |
| 101 | 101 | ||
| 102 | class WaitTreeSynchronizationObject : public WaitTreeExpandableItem { | 102 | class WaitTreeSynchronizationObject : public WaitTreeExpandableItem { |
| @@ -131,7 +131,7 @@ private: | |||
| 131 | class WaitTreeThread : public WaitTreeSynchronizationObject { | 131 | class WaitTreeThread : public WaitTreeSynchronizationObject { |
| 132 | Q_OBJECT | 132 | Q_OBJECT |
| 133 | public: | 133 | public: |
| 134 | explicit WaitTreeThread(const Kernel::Thread& thread); | 134 | explicit WaitTreeThread(const Kernel::KThread& thread); |
| 135 | ~WaitTreeThread() override; | 135 | ~WaitTreeThread() override; |
| 136 | 136 | ||
| 137 | QString GetText() const override; | 137 | QString GetText() const override; |
| @@ -149,14 +149,14 @@ public: | |||
| 149 | class WaitTreeThreadList : public WaitTreeExpandableItem { | 149 | class WaitTreeThreadList : public WaitTreeExpandableItem { |
| 150 | Q_OBJECT | 150 | Q_OBJECT |
| 151 | public: | 151 | public: |
| 152 | explicit WaitTreeThreadList(const std::vector<Kernel::Thread*>& list); | 152 | explicit WaitTreeThreadList(const std::vector<Kernel::KThread*>& list); |
| 153 | ~WaitTreeThreadList() override; | 153 | ~WaitTreeThreadList() override; |
| 154 | 154 | ||
| 155 | QString GetText() const override; | 155 | QString GetText() const override; |
| 156 | std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; | 156 | std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; |
| 157 | 157 | ||
| 158 | private: | 158 | private: |
| 159 | const std::vector<Kernel::Thread*>& thread_list; | 159 | const std::vector<Kernel::KThread*>& thread_list; |
| 160 | }; | 160 | }; |
| 161 | 161 | ||
| 162 | class WaitTreeModel : public QAbstractItemModel { | 162 | class WaitTreeModel : public QAbstractItemModel { |