diff options
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 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 | ||
| 144 | std::shared_ptr<KResourceLimit> Process::GetResourceLimit() const { | 147 | KResourceLimit* 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 | ||
| 380 | void 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. |