diff options
author | bunnei <bunneidev@gmail.com> | 2021-04-20 21:28:11 -0700 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2021-05-05 16:40:52 -0700 |
commit | b57c5a9b54b23a348d7e80e51943f27a54fb8c2f (patch) | |
tree | e3f3c81a2fddb94c43b6a1dd641c61a7ca9c8225 /src/core/hle/kernel/process.cpp | |
parent | 674122038ad01aae7eb4b6eff604f94fb8864bd4 (diff) |
hle: kernel: Migrate KResourceLimit to KAutoObject.
Diffstat (limited to 'src/core/hle/kernel/process.cpp')
-rw-r--r-- | src/core/hle/kernel/process.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 6780379231..315640bea8 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp @@ -138,10 +138,13 @@ ResultCode Process::Initialize(Process* process, Core::System& system, std::stri kernel.AppendNewProcess(process); + // Open a reference to the resource limit. + process->resource_limit->Open(); + return RESULT_SUCCESS; } -std::shared_ptr<KResourceLimit> Process::GetResourceLimit() const { +KResourceLimit* Process::GetResourceLimit() const { return resource_limit; } @@ -166,7 +169,10 @@ u64 Process::GetTotalPhysicalMemoryAvailable() const { const u64 capacity{resource_limit->GetFreeValue(LimitableResource::PhysicalMemory) + page_table->GetTotalHeapSize() + GetSystemResourceSize() + image_size + main_thread_stack_size}; - ASSERT(capacity == kernel.MemoryManager().GetSize(KMemoryManager::Pool::Application)); + if (const auto pool_size = kernel.MemoryManager().GetSize(KMemoryManager::Pool::Application); + capacity != pool_size) { + LOG_WARNING(Kernel, "capacity {} != application pool size {}", capacity, pool_size); + } if (capacity < memory_usage_capacity) { return capacity; } @@ -371,6 +377,16 @@ void Process::PrepareForTermination() { ChangeStatus(ProcessStatus::Exited); } +void Process::Finalize() { + // Release memory to the resource limit. + if (resource_limit != nullptr) { + resource_limit->Close(); + } + + // Perform inherited finalization. + KAutoObjectWithSlabHeapAndContainer<Process, KSynchronizationObject>::Finalize(); +} + /** * Attempts to find a TLS page that contains a free slot for * use by a thread. |