summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2022-12-06 22:13:42 +0100
committerLiam <byteslice@airmail.cc>2022-12-06 22:13:42 +0100
commit9704acb982eb3dfb4b2b6a090f5613d4ac57b196 (patch)
treeffc2dd5818b94e61e09eed5388cb821c90dc0896 /src/core
parentMerge pull request #9393 from liamwhite/more-vulkan (diff)
downloadyuzu-9704acb982eb3dfb4b2b6a090f5613d4ac57b196.tar
yuzu-9704acb982eb3dfb4b2b6a090f5613d4ac57b196.tar.gz
yuzu-9704acb982eb3dfb4b2b6a090f5613d4ac57b196.tar.bz2
yuzu-9704acb982eb3dfb4b2b6a090f5613d4ac57b196.tar.lz
yuzu-9704acb982eb3dfb4b2b6a090f5613d4ac57b196.tar.xz
yuzu-9704acb982eb3dfb4b2b6a090f5613d4ac57b196.tar.zst
yuzu-9704acb982eb3dfb4b2b6a090f5613d4ac57b196.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/core.cpp4
-rw-r--r--src/core/cpu_manager.cpp15
-rw-r--r--src/core/cpu_manager.h4
-rw-r--r--src/core/hle/kernel/kernel.cpp14
4 files changed, 20 insertions, 17 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 94d4e2212..a738f221f 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -389,7 +389,9 @@ struct System::Impl {
kernel.ShutdownCores();
cpu_manager.Shutdown();
debugger.reset();
- services->KillNVNFlinger();
+ if (services) {
+ services->KillNVNFlinger();
+ }
kernel.CloseServices();
services.reset();
service_manager.reset();
diff --git a/src/core/cpu_manager.cpp b/src/core/cpu_manager.cpp
index 0dd4c2196..04a11f444 100644
--- a/src/core/cpu_manager.cpp
+++ b/src/core/cpu_manager.cpp
@@ -20,23 +20,20 @@ namespace Core {
CpuManager::CpuManager(System& system_) : system{system_} {}
CpuManager::~CpuManager() = default;
-void CpuManager::ThreadStart(std::stop_token stop_token, CpuManager& cpu_manager,
- std::size_t core) {
- cpu_manager.RunThread(core);
-}
-
void CpuManager::Initialize() {
num_cores = is_multicore ? Core::Hardware::NUM_CPU_CORES : 1;
gpu_barrier = std::make_unique<Common::Barrier>(num_cores + 1);
for (std::size_t core = 0; core < num_cores; core++) {
- core_data[core].host_thread = std::jthread(ThreadStart, std::ref(*this), core);
+ core_data[core].host_thread =
+ std::jthread([this, core](std::stop_token token) { RunThread(token, core); });
}
}
void CpuManager::Shutdown() {
for (std::size_t core = 0; core < num_cores; core++) {
if (core_data[core].host_thread.joinable()) {
+ core_data[core].host_thread.request_stop();
core_data[core].host_thread.join();
}
}
@@ -184,7 +181,7 @@ void CpuManager::ShutdownThread() {
UNREACHABLE();
}
-void CpuManager::RunThread(std::size_t core) {
+void CpuManager::RunThread(std::stop_token token, std::size_t core) {
/// Initialization
system.RegisterCoreThread(core);
std::string name;
@@ -206,7 +203,9 @@ void CpuManager::RunThread(std::size_t core) {
});
// Running
- gpu_barrier->Sync();
+ if (!gpu_barrier->Sync(token)) {
+ return;
+ }
if (!is_async_gpu && !is_multicore) {
system.GPU().ObtainContext();
diff --git a/src/core/cpu_manager.h b/src/core/cpu_manager.h
index 374367468..0deea9c58 100644
--- a/src/core/cpu_manager.h
+++ b/src/core/cpu_manager.h
@@ -81,12 +81,10 @@ private:
void SingleCoreRunGuestThread();
void SingleCoreRunIdleThread();
- static void ThreadStart(std::stop_token stop_token, CpuManager& cpu_manager, std::size_t core);
-
void GuestActivate();
void HandleInterrupt();
void ShutdownThread();
- void RunThread(std::size_t core);
+ void RunThread(std::stop_token stop_token, std::size_t core);
struct CoreData {
std::shared_ptr<Common::Fiber> host_context;
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 288f97df5..0eb74a422 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -104,12 +104,16 @@ struct KernelCore::Impl {
}
void CloseCurrentProcess() {
- (*current_process).Finalize();
- // current_process->Close();
- // TODO: The current process should be destroyed based on accurate ref counting after
+ KProcess* old_process = current_process.exchange(nullptr);
+ if (old_process == nullptr) {
+ return;
+ }
+
+ // old_process->Close();
+ // TODO: The process should be destroyed based on accurate ref counting after
// calling Close(). Adding a manual Destroy() call instead to avoid a memory leak.
- (*current_process).Destroy();
- current_process = nullptr;
+ old_process->Finalize();
+ old_process->Destroy();
}
void Shutdown() {