summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/kernel.cpp
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2020-03-08 22:39:41 -0400
committerGravatar Fernando Sahmkow2020-06-27 11:35:42 -0400
commitab9aae28bf5daa5fa7105bb4ef41b6d0b3c9cdc1 (patch)
treeec11dc90eb2cad49237eecc98766f61b04724254 /src/core/hle/kernel/kernel.cpp
parentScheduler: Set last running time on thread. (diff)
downloadyuzu-ab9aae28bf5daa5fa7105bb4ef41b6d0b3c9cdc1.tar.gz
yuzu-ab9aae28bf5daa5fa7105bb4ef41b6d0b3c9cdc1.tar.xz
yuzu-ab9aae28bf5daa5fa7105bb4ef41b6d0b3c9cdc1.zip
General: Initial Setup for Single Core.
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
-rw-r--r--src/core/hle/kernel/kernel.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 721ab1e70..4a091ea38 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -113,6 +113,10 @@ struct KernelCore::Impl {
113 explicit Impl(Core::System& system, KernelCore& kernel) 113 explicit Impl(Core::System& system, KernelCore& kernel)
114 : global_scheduler{kernel}, synchronization{system}, time_manager{system}, system{system} {} 114 : global_scheduler{kernel}, synchronization{system}, time_manager{system}, system{system} {}
115 115
116 void SetMulticore(bool is_multicore) {
117 this->is_multicore = is_multicore;
118 }
119
116 void Initialize(KernelCore& kernel) { 120 void Initialize(KernelCore& kernel) {
117 Shutdown(); 121 Shutdown();
118 122
@@ -237,6 +241,9 @@ struct KernelCore::Impl {
237 241
238 void RegisterCoreThread(std::size_t core_id) { 242 void RegisterCoreThread(std::size_t core_id) {
239 std::unique_lock lock{register_thread_mutex}; 243 std::unique_lock lock{register_thread_mutex};
244 if (!is_multicore) {
245 single_core_thread_id = std::this_thread::get_id();
246 }
240 const std::thread::id this_id = std::this_thread::get_id(); 247 const std::thread::id this_id = std::this_thread::get_id();
241 const auto it = host_thread_ids.find(this_id); 248 const auto it = host_thread_ids.find(this_id);
242 ASSERT(core_id < Core::Hardware::NUM_CPU_CORES); 249 ASSERT(core_id < Core::Hardware::NUM_CPU_CORES);
@@ -258,6 +265,11 @@ struct KernelCore::Impl {
258 265
259 u32 GetCurrentHostThreadID() const { 266 u32 GetCurrentHostThreadID() const {
260 const std::thread::id this_id = std::this_thread::get_id(); 267 const std::thread::id this_id = std::this_thread::get_id();
268 if (!is_multicore) {
269 if (single_core_thread_id == this_id) {
270 return static_cast<u32>(system.GetCpuManager().CurrentCore());
271 }
272 }
261 const auto it = host_thread_ids.find(this_id); 273 const auto it = host_thread_ids.find(this_id);
262 if (it == host_thread_ids.end()) { 274 if (it == host_thread_ids.end()) {
263 return Core::INVALID_HOST_THREAD_ID; 275 return Core::INVALID_HOST_THREAD_ID;
@@ -378,6 +390,9 @@ struct KernelCore::Impl {
378 390
379 std::array<std::shared_ptr<Thread>, Core::Hardware::NUM_CPU_CORES> suspend_threads{}; 391 std::array<std::shared_ptr<Thread>, Core::Hardware::NUM_CPU_CORES> suspend_threads{};
380 392
393 bool is_multicore{};
394 std::thread::id single_core_thread_id{};
395
381 // System context 396 // System context
382 Core::System& system; 397 Core::System& system;
383}; 398};
@@ -387,6 +402,10 @@ KernelCore::~KernelCore() {
387 Shutdown(); 402 Shutdown();
388} 403}
389 404
405void KernelCore::SetMulticore(bool is_multicore) {
406 impl->SetMulticore(is_multicore);
407}
408
390void KernelCore::Initialize() { 409void KernelCore::Initialize() {
391 impl->Initialize(*this); 410 impl->Initialize(*this);
392} 411}