mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2025-07-21 22:45:45 +00:00
hle: kernel: Migrate KResourceLimit to KAutoObject.
This commit is contained in:
parent
674122038a
commit
b57c5a9b54
13 changed files with 198 additions and 123 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue