diff options
| author | 2021-01-24 22:54:37 -0800 | |
|---|---|---|
| committer | 2021-01-28 21:42:26 -0800 | |
| commit | 3856564727e3efcf85fb0c1e5431cab22d818370 (patch) | |
| tree | 589d4322c34c6ae15184b322b9302c33f1c34087 /src/core/hle/kernel | |
| parent | hle: kernel: threading: Fix bug with host thread naming. (diff) | |
| download | yuzu-3856564727e3efcf85fb0c1e5431cab22d818370.tar.gz yuzu-3856564727e3efcf85fb0c1e5431cab22d818370.tar.xz yuzu-3856564727e3efcf85fb0c1e5431cab22d818370.zip | |
hle: kernel: process: Add state lock.
Diffstat (limited to 'src/core/hle/kernel')
| -rw-r--r-- | src/core/hle/kernel/process.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/process.h | 6 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 11 |
3 files changed, 15 insertions, 6 deletions
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 9f4583b49..0edbfc4cc 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp | |||
| @@ -138,7 +138,7 @@ std::shared_ptr<ResourceLimit> Process::GetResourceLimit() const { | |||
| 138 | 138 | ||
| 139 | void Process::IncrementThreadCount() { | 139 | void Process::IncrementThreadCount() { |
| 140 | ASSERT(num_threads >= 0); | 140 | ASSERT(num_threads >= 0); |
| 141 | ++num_created_threads; | 141 | num_created_threads++; |
| 142 | 142 | ||
| 143 | if (const auto count = ++num_threads; count > peak_num_threads) { | 143 | if (const auto count = ++num_threads; count > peak_num_threads) { |
| 144 | peak_num_threads = count; | 144 | peak_num_threads = count; |
| @@ -443,7 +443,7 @@ bool Process::IsSignaled() const { | |||
| 443 | Process::Process(Core::System& system) | 443 | Process::Process(Core::System& system) |
| 444 | : KSynchronizationObject{system.Kernel()}, | 444 | : KSynchronizationObject{system.Kernel()}, |
| 445 | page_table{std::make_unique<Memory::PageTable>(system)}, handle_table{system.Kernel()}, | 445 | page_table{std::make_unique<Memory::PageTable>(system)}, handle_table{system.Kernel()}, |
| 446 | address_arbiter{system}, condition_var{system}, system{system} {} | 446 | address_arbiter{system}, condition_var{system}, state_lock{system.Kernel()}, system{system} {} |
| 447 | 447 | ||
| 448 | Process::~Process() = default; | 448 | Process::~Process() = default; |
| 449 | 449 | ||
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 11d78f3a8..26e647743 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h | |||
| @@ -348,6 +348,10 @@ public: | |||
| 348 | void PinCurrentThread(); | 348 | void PinCurrentThread(); |
| 349 | void UnpinCurrentThread(); | 349 | void UnpinCurrentThread(); |
| 350 | 350 | ||
| 351 | KLightLock& GetStateLock() { | ||
| 352 | return state_lock; | ||
| 353 | } | ||
| 354 | |||
| 351 | /////////////////////////////////////////////////////////////////////////////////////////////// | 355 | /////////////////////////////////////////////////////////////////////////////////////////////// |
| 352 | // Thread-local storage management | 356 | // Thread-local storage management |
| 353 | 357 | ||
| @@ -472,6 +476,8 @@ private: | |||
| 472 | 476 | ||
| 473 | KThread* exception_thread{}; | 477 | KThread* exception_thread{}; |
| 474 | 478 | ||
| 479 | KLightLock state_lock; | ||
| 480 | |||
| 475 | /// System context | 481 | /// System context |
| 476 | Core::System& system; | 482 | Core::System& system; |
| 477 | }; | 483 | }; |
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index dbef854f8..7fd514e9d 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -1450,11 +1450,14 @@ static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr e | |||
| 1450 | Svc::ResultInvalidPriority); | 1450 | Svc::ResultInvalidPriority); |
| 1451 | R_UNLESS(process.CheckThreadPriority(priority), Svc::ResultInvalidPriority); | 1451 | R_UNLESS(process.CheckThreadPriority(priority), Svc::ResultInvalidPriority); |
| 1452 | 1452 | ||
| 1453 | ASSERT(kernel.CurrentProcess()->GetResourceLimit()->Reserve(ResourceType::Threads, 1)); | 1453 | ASSERT(process.GetResourceLimit()->Reserve(ResourceType::Threads, 1)); |
| 1454 | 1454 | ||
| 1455 | CASCADE_RESULT(std::shared_ptr<KThread> thread, | 1455 | std::shared_ptr<KThread> thread; |
| 1456 | KThread::Create(system, ThreadType::User, "", entry_point, priority, arg, | 1456 | { |
| 1457 | core_id, stack_bottom, &process)); | 1457 | KScopedLightLock lk{process.GetStateLock()}; |
| 1458 | CASCADE_RESULT(thread, KThread::Create(system, ThreadType::User, "", entry_point, priority, | ||
| 1459 | arg, core_id, stack_bottom, &process)); | ||
| 1460 | } | ||
| 1458 | 1461 | ||
| 1459 | const auto new_thread_handle = process.GetHandleTable().Create(thread); | 1462 | const auto new_thread_handle = process.GetHandleTable().Create(thread); |
| 1460 | if (new_thread_handle.Failed()) { | 1463 | if (new_thread_handle.Failed()) { |