mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-11-26 13:05:40 +01:00
hle: kernel: process: Add state lock.
This commit is contained in:
parent
ff46ef7ea3
commit
3856564727
@ -138,7 +138,7 @@ std::shared_ptr<ResourceLimit> Process::GetResourceLimit() const {
|
|||||||
|
|
||||||
void Process::IncrementThreadCount() {
|
void Process::IncrementThreadCount() {
|
||||||
ASSERT(num_threads >= 0);
|
ASSERT(num_threads >= 0);
|
||||||
++num_created_threads;
|
num_created_threads++;
|
||||||
|
|
||||||
if (const auto count = ++num_threads; count > peak_num_threads) {
|
if (const auto count = ++num_threads; count > peak_num_threads) {
|
||||||
peak_num_threads = count;
|
peak_num_threads = count;
|
||||||
@ -443,7 +443,7 @@ bool Process::IsSignaled() const {
|
|||||||
Process::Process(Core::System& system)
|
Process::Process(Core::System& system)
|
||||||
: KSynchronizationObject{system.Kernel()},
|
: KSynchronizationObject{system.Kernel()},
|
||||||
page_table{std::make_unique<Memory::PageTable>(system)}, handle_table{system.Kernel()},
|
page_table{std::make_unique<Memory::PageTable>(system)}, handle_table{system.Kernel()},
|
||||||
address_arbiter{system}, condition_var{system}, system{system} {}
|
address_arbiter{system}, condition_var{system}, state_lock{system.Kernel()}, system{system} {}
|
||||||
|
|
||||||
Process::~Process() = default;
|
Process::~Process() = default;
|
||||||
|
|
||||||
|
@ -348,6 +348,10 @@ public:
|
|||||||
void PinCurrentThread();
|
void PinCurrentThread();
|
||||||
void UnpinCurrentThread();
|
void UnpinCurrentThread();
|
||||||
|
|
||||||
|
KLightLock& GetStateLock() {
|
||||||
|
return state_lock;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Thread-local storage management
|
// Thread-local storage management
|
||||||
|
|
||||||
@ -472,6 +476,8 @@ private:
|
|||||||
|
|
||||||
KThread* exception_thread{};
|
KThread* exception_thread{};
|
||||||
|
|
||||||
|
KLightLock state_lock;
|
||||||
|
|
||||||
/// System context
|
/// System context
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
};
|
};
|
||||||
|
@ -1450,11 +1450,14 @@ static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr e
|
|||||||
Svc::ResultInvalidPriority);
|
Svc::ResultInvalidPriority);
|
||||||
R_UNLESS(process.CheckThreadPriority(priority), Svc::ResultInvalidPriority);
|
R_UNLESS(process.CheckThreadPriority(priority), Svc::ResultInvalidPriority);
|
||||||
|
|
||||||
ASSERT(kernel.CurrentProcess()->GetResourceLimit()->Reserve(ResourceType::Threads, 1));
|
ASSERT(process.GetResourceLimit()->Reserve(ResourceType::Threads, 1));
|
||||||
|
|
||||||
CASCADE_RESULT(std::shared_ptr<KThread> thread,
|
std::shared_ptr<KThread> thread;
|
||||||
KThread::Create(system, ThreadType::User, "", entry_point, priority, arg,
|
{
|
||||||
core_id, stack_bottom, &process));
|
KScopedLightLock lk{process.GetStateLock()};
|
||||||
|
CASCADE_RESULT(thread, KThread::Create(system, ThreadType::User, "", entry_point, priority,
|
||||||
|
arg, core_id, stack_bottom, &process));
|
||||||
|
}
|
||||||
|
|
||||||
const auto new_thread_handle = process.GetHandleTable().Create(thread);
|
const auto new_thread_handle = process.GetHandleTable().Create(thread);
|
||||||
if (new_thread_handle.Failed()) {
|
if (new_thread_handle.Failed()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user