diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 14 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.h | 16 |
2 files changed, 26 insertions, 4 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 34da7c23b..6387d0c29 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -61,6 +61,7 @@ struct KernelCore::Impl { | |||
| 61 | global_scheduler_context = std::make_unique<Kernel::GlobalSchedulerContext>(kernel); | 61 | global_scheduler_context = std::make_unique<Kernel::GlobalSchedulerContext>(kernel); |
| 62 | global_handle_table = std::make_unique<Kernel::KHandleTable>(kernel); | 62 | global_handle_table = std::make_unique<Kernel::KHandleTable>(kernel); |
| 63 | global_handle_table->Initialize(KHandleTable::MaxTableSize); | 63 | global_handle_table->Initialize(KHandleTable::MaxTableSize); |
| 64 | default_service_thread = CreateServiceThread(kernel, "DefaultServiceThread"); | ||
| 64 | 65 | ||
| 65 | is_phantom_mode_for_singlecore = false; | 66 | is_phantom_mode_for_singlecore = false; |
| 66 | 67 | ||
| @@ -677,6 +678,12 @@ struct KernelCore::Impl { | |||
| 677 | 678 | ||
| 678 | void ReleaseServiceThread(std::weak_ptr<Kernel::ServiceThread> service_thread) { | 679 | void ReleaseServiceThread(std::weak_ptr<Kernel::ServiceThread> service_thread) { |
| 679 | if (auto strong_ptr = service_thread.lock()) { | 680 | if (auto strong_ptr = service_thread.lock()) { |
| 681 | if (strong_ptr == default_service_thread.lock()) { | ||
| 682 | // Nothing to do here, the service is using default_service_thread, which will be | ||
| 683 | // released on shutdown. | ||
| 684 | return; | ||
| 685 | } | ||
| 686 | |||
| 680 | service_threads_manager.QueueWork( | 687 | service_threads_manager.QueueWork( |
| 681 | [this, strong_ptr{std::move(strong_ptr)}]() { service_threads.erase(strong_ptr); }); | 688 | [this, strong_ptr{std::move(strong_ptr)}]() { service_threads.erase(strong_ptr); }); |
| 682 | } | 689 | } |
| @@ -739,7 +746,8 @@ struct KernelCore::Impl { | |||
| 739 | std::unique_ptr<KMemoryLayout> memory_layout; | 746 | std::unique_ptr<KMemoryLayout> memory_layout; |
| 740 | 747 | ||
| 741 | // Threads used for services | 748 | // Threads used for services |
| 742 | std::unordered_set<std::shared_ptr<Kernel::ServiceThread>> service_threads; | 749 | std::unordered_set<std::shared_ptr<ServiceThread>> service_threads; |
| 750 | std::weak_ptr<ServiceThread> default_service_thread; | ||
| 743 | Common::ThreadWorker service_threads_manager; | 751 | Common::ThreadWorker service_threads_manager; |
| 744 | 752 | ||
| 745 | std::array<KThread*, Core::Hardware::NUM_CPU_CORES> suspend_threads; | 753 | std::array<KThread*, Core::Hardware::NUM_CPU_CORES> suspend_threads; |
| @@ -1065,6 +1073,10 @@ std::weak_ptr<Kernel::ServiceThread> KernelCore::CreateServiceThread(const std:: | |||
| 1065 | return impl->CreateServiceThread(*this, name); | 1073 | return impl->CreateServiceThread(*this, name); |
| 1066 | } | 1074 | } |
| 1067 | 1075 | ||
| 1076 | std::weak_ptr<Kernel::ServiceThread> KernelCore::GetDefaultServiceThread() const { | ||
| 1077 | return impl->default_service_thread; | ||
| 1078 | } | ||
| 1079 | |||
| 1068 | void KernelCore::ReleaseServiceThread(std::weak_ptr<Kernel::ServiceThread> service_thread) { | 1080 | void KernelCore::ReleaseServiceThread(std::weak_ptr<Kernel::ServiceThread> service_thread) { |
| 1069 | impl->ReleaseServiceThread(service_thread); | 1081 | impl->ReleaseServiceThread(service_thread); |
| 1070 | } | 1082 | } |
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 4c68e96df..24e26fa44 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h | |||
| @@ -271,9 +271,11 @@ public: | |||
| 271 | void ExitSVCProfile(); | 271 | void ExitSVCProfile(); |
| 272 | 272 | ||
| 273 | /** | 273 | /** |
| 274 | * Creates an HLE service thread, which are used to execute service routines asynchronously. | 274 | * Creates a host thread to execute HLE service requests, which are used to execute service |
| 275 | * While these are allocated per ServerSession, these need to be owned and managed outside | 275 | * routines asynchronously. While these are allocated per ServerSession, these need to be owned |
| 276 | * of ServerSession to avoid a circular dependency. | 276 | * and managed outside of ServerSession to avoid a circular dependency. In general, most |
| 277 | * services can just use the default service thread, and not need their own host service thread. | ||
| 278 | * See GetDefaultServiceThread. | ||
| 277 | * @param name String name for the ServerSession creating this thread, used for debug | 279 | * @param name String name for the ServerSession creating this thread, used for debug |
| 278 | * purposes. | 280 | * purposes. |
| 279 | * @returns The a weak pointer newly created service thread. | 281 | * @returns The a weak pointer newly created service thread. |
| @@ -281,6 +283,14 @@ public: | |||
| 281 | std::weak_ptr<Kernel::ServiceThread> CreateServiceThread(const std::string& name); | 283 | std::weak_ptr<Kernel::ServiceThread> CreateServiceThread(const std::string& name); |
| 282 | 284 | ||
| 283 | /** | 285 | /** |
| 286 | * Gets the default host service thread, which executes HLE service requests. Unless service | ||
| 287 | * requests need to block on the host, the default service thread should be used in favor of | ||
| 288 | * creating a new service thread. | ||
| 289 | * @returns The a weak pointer for the default service thread. | ||
| 290 | */ | ||
| 291 | std::weak_ptr<Kernel::ServiceThread> GetDefaultServiceThread() const; | ||
| 292 | |||
| 293 | /** | ||
| 284 | * Releases a HLE service thread, instructing KernelCore to free it. This should be called when | 294 | * Releases a HLE service thread, instructing KernelCore to free it. This should be called when |
| 285 | * the ServerSession associated with the thread is destroyed. | 295 | * the ServerSession associated with the thread is destroyed. |
| 286 | * @param service_thread Service thread to release. | 296 | * @param service_thread Service thread to release. |