summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/process.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2021-04-20 21:28:11 -0700
committerGravatar bunnei2021-05-05 16:40:52 -0700
commitb57c5a9b54b23a348d7e80e51943f27a54fb8c2f (patch)
treee3f3c81a2fddb94c43b6a1dd641c61a7ca9c8225 /src/core/hle/kernel/process.cpp
parenthle: kernel: svc: Migrate WaitSynchronization. (diff)
downloadyuzu-b57c5a9b54b23a348d7e80e51943f27a54fb8c2f.tar.gz
yuzu-b57c5a9b54b23a348d7e80e51943f27a54fb8c2f.tar.xz
yuzu-b57c5a9b54b23a348d7e80e51943f27a54fb8c2f.zip
hle: kernel: Migrate KResourceLimit to KAutoObject.
Diffstat (limited to 'src/core/hle/kernel/process.cpp')
-rw-r--r--src/core/hle/kernel/process.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp
index 678037923..315640bea 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
138 138
139 kernel.AppendNewProcess(process); 139 kernel.AppendNewProcess(process);
140 140
141 // Open a reference to the resource limit.
142 process->resource_limit->Open();
143
141 return RESULT_SUCCESS; 144 return RESULT_SUCCESS;
142} 145}
143 146
144std::shared_ptr<KResourceLimit> Process::GetResourceLimit() const { 147KResourceLimit* Process::GetResourceLimit() const {
145 return resource_limit; 148 return resource_limit;
146} 149}
147 150
@@ -166,7 +169,10 @@ u64 Process::GetTotalPhysicalMemoryAvailable() const {
166 const u64 capacity{resource_limit->GetFreeValue(LimitableResource::PhysicalMemory) + 169 const u64 capacity{resource_limit->GetFreeValue(LimitableResource::PhysicalMemory) +
167 page_table->GetTotalHeapSize() + GetSystemResourceSize() + image_size + 170 page_table->GetTotalHeapSize() + GetSystemResourceSize() + image_size +
168 main_thread_stack_size}; 171 main_thread_stack_size};
169 ASSERT(capacity == kernel.MemoryManager().GetSize(KMemoryManager::Pool::Application)); 172 if (const auto pool_size = kernel.MemoryManager().GetSize(KMemoryManager::Pool::Application);
173 capacity != pool_size) {
174 LOG_WARNING(Kernel, "capacity {} != application pool size {}", capacity, pool_size);
175 }
170 if (capacity < memory_usage_capacity) { 176 if (capacity < memory_usage_capacity) {
171 return capacity; 177 return capacity;
172 } 178 }
@@ -371,6 +377,16 @@ void Process::PrepareForTermination() {
371 ChangeStatus(ProcessStatus::Exited); 377 ChangeStatus(ProcessStatus::Exited);
372} 378}
373 379
380void Process::Finalize() {
381 // Release memory to the resource limit.
382 if (resource_limit != nullptr) {
383 resource_limit->Close();
384 }
385
386 // Perform inherited finalization.
387 KAutoObjectWithSlabHeapAndContainer<Process, KSynchronizationObject>::Finalize();
388}
389
374/** 390/**
375 * Attempts to find a TLS page that contains a free slot for 391 * Attempts to find a TLS page that contains a free slot for
376 * use by a thread. 392 * use by a thread.