diff options
| author | 2021-02-03 14:53:25 -0800 | |
|---|---|---|
| committer | 2021-02-03 14:53:25 -0800 | |
| commit | b0c97526633dffdf105f6d0a854ee2d02ae5a516 (patch) | |
| tree | 9da902b04fb9424a3f1e32ee05b81327da521157 /src/core/hle/kernel/process.cpp | |
| parent | Merge pull request #5842 from german77/userfix (diff) | |
| parent | Simplify limitableresource names (diff) | |
| download | yuzu-b0c97526633dffdf105f6d0a854ee2d02ae5a516.tar.gz yuzu-b0c97526633dffdf105f6d0a854ee2d02ae5a516.tar.xz yuzu-b0c97526633dffdf105f6d0a854ee2d02ae5a516.zip | |
Merge pull request #5848 from ogniK5377/k-resourcelimit
kernel: Rewrite resource limit to be more accurate
Diffstat (limited to 'src/core/hle/kernel/process.cpp')
| -rw-r--r-- | src/core/hle/kernel/process.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 0edbfc4cc..afdb27c54 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include "core/file_sys/program_metadata.h" | 15 | #include "core/file_sys/program_metadata.h" |
| 16 | #include "core/hle/kernel/code_set.h" | 16 | #include "core/hle/kernel/code_set.h" |
| 17 | #include "core/hle/kernel/errors.h" | 17 | #include "core/hle/kernel/errors.h" |
| 18 | #include "core/hle/kernel/k_resource_limit.h" | ||
| 18 | #include "core/hle/kernel/k_scheduler.h" | 19 | #include "core/hle/kernel/k_scheduler.h" |
| 19 | #include "core/hle/kernel/k_thread.h" | 20 | #include "core/hle/kernel/k_thread.h" |
| 20 | #include "core/hle/kernel/kernel.h" | 21 | #include "core/hle/kernel/kernel.h" |
| @@ -22,7 +23,6 @@ | |||
| 22 | #include "core/hle/kernel/memory/page_table.h" | 23 | #include "core/hle/kernel/memory/page_table.h" |
| 23 | #include "core/hle/kernel/memory/slab_heap.h" | 24 | #include "core/hle/kernel/memory/slab_heap.h" |
| 24 | #include "core/hle/kernel/process.h" | 25 | #include "core/hle/kernel/process.h" |
| 25 | #include "core/hle/kernel/resource_limit.h" | ||
| 26 | #include "core/hle/lock.h" | 26 | #include "core/hle/lock.h" |
| 27 | #include "core/memory.h" | 27 | #include "core/memory.h" |
| 28 | #include "core/settings.h" | 28 | #include "core/settings.h" |
| @@ -116,7 +116,7 @@ std::shared_ptr<Process> Process::Create(Core::System& system, std::string name, | |||
| 116 | 116 | ||
| 117 | std::shared_ptr<Process> process = std::make_shared<Process>(system); | 117 | std::shared_ptr<Process> process = std::make_shared<Process>(system); |
| 118 | process->name = std::move(name); | 118 | process->name = std::move(name); |
| 119 | process->resource_limit = ResourceLimit::Create(kernel); | 119 | process->resource_limit = std::make_shared<KResourceLimit>(kernel, system); |
| 120 | process->status = ProcessStatus::Created; | 120 | process->status = ProcessStatus::Created; |
| 121 | process->program_id = 0; | 121 | process->program_id = 0; |
| 122 | process->process_id = type == ProcessType::KernelInternal ? kernel.CreateNewKernelProcessID() | 122 | process->process_id = type == ProcessType::KernelInternal ? kernel.CreateNewKernelProcessID() |
| @@ -132,7 +132,7 @@ std::shared_ptr<Process> Process::Create(Core::System& system, std::string name, | |||
| 132 | return process; | 132 | return process; |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | std::shared_ptr<ResourceLimit> Process::GetResourceLimit() const { | 135 | std::shared_ptr<KResourceLimit> Process::GetResourceLimit() const { |
| 136 | return resource_limit; | 136 | return resource_limit; |
| 137 | } | 137 | } |
| 138 | 138 | ||
| @@ -154,7 +154,7 @@ void Process::DecrementThreadCount() { | |||
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | u64 Process::GetTotalPhysicalMemoryAvailable() const { | 156 | u64 Process::GetTotalPhysicalMemoryAvailable() const { |
| 157 | const u64 capacity{resource_limit->GetCurrentResourceValue(ResourceType::PhysicalMemory) + | 157 | const u64 capacity{resource_limit->GetFreeValue(LimitableResource::PhysicalMemory) + |
| 158 | page_table->GetTotalHeapSize() + GetSystemResourceSize() + image_size + | 158 | page_table->GetTotalHeapSize() + GetSystemResourceSize() + image_size + |
| 159 | main_thread_stack_size}; | 159 | main_thread_stack_size}; |
| 160 | 160 | ||
| @@ -308,13 +308,13 @@ ResultCode Process::LoadFromMetadata(const FileSys::ProgramMetadata& metadata, | |||
| 308 | 308 | ||
| 309 | // Set initial resource limits | 309 | // Set initial resource limits |
| 310 | resource_limit->SetLimitValue( | 310 | resource_limit->SetLimitValue( |
| 311 | ResourceType::PhysicalMemory, | 311 | LimitableResource::PhysicalMemory, |
| 312 | kernel.MemoryManager().GetSize(Memory::MemoryManager::Pool::Application)); | 312 | kernel.MemoryManager().GetSize(Memory::MemoryManager::Pool::Application)); |
| 313 | resource_limit->SetLimitValue(ResourceType::Threads, 608); | 313 | resource_limit->SetLimitValue(LimitableResource::Threads, 608); |
| 314 | resource_limit->SetLimitValue(ResourceType::Events, 700); | 314 | resource_limit->SetLimitValue(LimitableResource::Events, 700); |
| 315 | resource_limit->SetLimitValue(ResourceType::TransferMemory, 128); | 315 | resource_limit->SetLimitValue(LimitableResource::TransferMemory, 128); |
| 316 | resource_limit->SetLimitValue(ResourceType::Sessions, 894); | 316 | resource_limit->SetLimitValue(LimitableResource::Sessions, 894); |
| 317 | ASSERT(resource_limit->Reserve(ResourceType::PhysicalMemory, code_size)); | 317 | ASSERT(resource_limit->Reserve(LimitableResource::PhysicalMemory, code_size)); |
| 318 | 318 | ||
| 319 | // Create TLS region | 319 | // Create TLS region |
| 320 | tls_region_address = CreateTLSRegion(); | 320 | tls_region_address = CreateTLSRegion(); |
| @@ -331,8 +331,8 @@ void Process::Run(s32 main_thread_priority, u64 stack_size) { | |||
| 331 | ChangeStatus(ProcessStatus::Running); | 331 | ChangeStatus(ProcessStatus::Running); |
| 332 | 332 | ||
| 333 | SetupMainThread(system, *this, main_thread_priority, main_thread_stack_top); | 333 | SetupMainThread(system, *this, main_thread_priority, main_thread_stack_top); |
| 334 | resource_limit->Reserve(ResourceType::Threads, 1); | 334 | resource_limit->Reserve(LimitableResource::Threads, 1); |
| 335 | resource_limit->Reserve(ResourceType::PhysicalMemory, main_thread_stack_size); | 335 | resource_limit->Reserve(LimitableResource::PhysicalMemory, main_thread_stack_size); |
| 336 | } | 336 | } |
| 337 | 337 | ||
| 338 | void Process::PrepareForTermination() { | 338 | void Process::PrepareForTermination() { |