diff options
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r-- | src/core/hle/kernel/k_scheduler.cpp | 2 | ||||
-rw-r--r-- | src/core/hle/kernel/kernel.cpp | 23 |
2 files changed, 11 insertions, 14 deletions
diff --git a/src/core/hle/kernel/k_scheduler.cpp b/src/core/hle/kernel/k_scheduler.cpp index 31cec990e..f900b2e7a 100644 --- a/src/core/hle/kernel/k_scheduler.cpp +++ b/src/core/hle/kernel/k_scheduler.cpp @@ -49,8 +49,6 @@ void KScheduler::RescheduleCores(KernelCore& kernel, u64 cores_pending_reschedul if (!must_context_switch || core != current_core) { auto& phys_core = kernel.PhysicalCore(core); phys_core.Interrupt(); - } else { - must_context_switch = true; } cores_pending_reschedule &= ~(1ULL << core); } diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 93c0cdaee..e5cf9abb3 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -52,7 +52,8 @@ namespace Kernel { struct KernelCore::Impl { explicit Impl(Core::System& system_, KernelCore& kernel_) - : time_manager{system_}, object_list_container{kernel_}, system{system_} {} + : time_manager{system_}, object_list_container{kernel_}, + service_threads_manager{1, "yuzu:ServiceThreadsManager"}, system{system_} {} void SetMulticore(bool is_multi) { is_multicore = is_multi; @@ -708,24 +709,22 @@ struct KernelCore::Impl { std::weak_ptr<Kernel::ServiceThread> CreateServiceThread(KernelCore& kernel, const std::string& name) { auto service_thread = std::make_shared<Kernel::ServiceThread>(kernel, 1, name); - { - std::lock_guard lk(service_threads_lock); - service_threads.emplace(service_thread); - } + + service_threads_manager.QueueWork( + [this, service_thread]() { service_threads.emplace(service_thread); }); + return service_thread; } void ReleaseServiceThread(std::weak_ptr<Kernel::ServiceThread> service_thread) { - auto strong_ptr = service_thread.lock(); - { - std::lock_guard lk(service_threads_lock); - service_threads.erase(strong_ptr); + if (auto strong_ptr = service_thread.lock()) { + service_threads_manager.QueueWork( + [this, strong_ptr{std::move(strong_ptr)}]() { service_threads.erase(strong_ptr); }); } } void ClearServiceThreads() { - std::lock_guard lk(service_threads_lock); - service_threads.clear(); + service_threads_manager.QueueWork([this]() { service_threads.clear(); }); } std::mutex server_ports_lock; @@ -733,7 +732,6 @@ struct KernelCore::Impl { std::mutex registered_objects_lock; std::mutex registered_in_use_objects_lock; std::mutex dummy_thread_lock; - std::mutex service_threads_lock; std::atomic<u32> next_object_id{0}; std::atomic<u64> next_kernel_process_id{KProcess::InitialKIPIDMin}; @@ -784,6 +782,7 @@ struct KernelCore::Impl { // Threads used for services std::unordered_set<std::shared_ptr<Kernel::ServiceThread>> service_threads; + Common::ThreadWorker service_threads_manager; std::array<KThread*, Core::Hardware::NUM_CPU_CORES> suspend_threads; std::array<Core::CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES> interrupts{}; |