diff options
Diffstat (limited to 'src/core/hle/kernel/process.cpp')
| -rw-r--r-- | src/core/hle/kernel/process.cpp | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 9d5956ead..dd01f3924 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp | |||
| @@ -120,9 +120,7 @@ std::shared_ptr<Process> Process::Create(Core::System& system, std::string name, | |||
| 120 | std::shared_ptr<Process> process = std::make_shared<Process>(system); | 120 | std::shared_ptr<Process> process = std::make_shared<Process>(system); |
| 121 | process->name = std::move(name); | 121 | process->name = std::move(name); |
| 122 | 122 | ||
| 123 | // TODO: This is inaccurate | 123 | process->resource_limit = kernel.GetSystemResourceLimit(); |
| 124 | // The process should hold a reference to the kernel-wide resource limit. | ||
| 125 | process->resource_limit = std::make_shared<KResourceLimit>(kernel, system); | ||
| 126 | process->status = ProcessStatus::Created; | 124 | process->status = ProcessStatus::Created; |
| 127 | process->program_id = 0; | 125 | process->program_id = 0; |
| 128 | process->process_id = type == ProcessType::KernelInternal ? kernel.CreateNewKernelProcessID() | 126 | process->process_id = type == ProcessType::KernelInternal ? kernel.CreateNewKernelProcessID() |
| @@ -160,17 +158,13 @@ void Process::DecrementThreadCount() { | |||
| 160 | } | 158 | } |
| 161 | 159 | ||
| 162 | u64 Process::GetTotalPhysicalMemoryAvailable() const { | 160 | u64 Process::GetTotalPhysicalMemoryAvailable() const { |
| 163 | // TODO: This is expected to always return the application memory pool size after accurately | ||
| 164 | // reserving kernel resources. The current workaround uses a process-local resource limit of | ||
| 165 | // application memory pool size, which is inaccurate. | ||
| 166 | const u64 capacity{resource_limit->GetFreeValue(LimitableResource::PhysicalMemory) + | 161 | const u64 capacity{resource_limit->GetFreeValue(LimitableResource::PhysicalMemory) + |
| 167 | page_table->GetTotalHeapSize() + GetSystemResourceSize() + image_size + | 162 | page_table->GetTotalHeapSize() + GetSystemResourceSize() + image_size + |
| 168 | main_thread_stack_size}; | 163 | main_thread_stack_size}; |
| 169 | 164 | ASSERT(capacity == kernel.MemoryManager().GetSize(KMemoryManager::Pool::Application)); | |
| 170 | if (capacity < memory_usage_capacity) { | 165 | if (capacity < memory_usage_capacity) { |
| 171 | return capacity; | 166 | return capacity; |
| 172 | } | 167 | } |
| 173 | |||
| 174 | return memory_usage_capacity; | 168 | return memory_usage_capacity; |
| 175 | } | 169 | } |
| 176 | 170 | ||
| @@ -272,10 +266,6 @@ ResultCode Process::LoadFromMetadata(const FileSys::ProgramMetadata& metadata, | |||
| 272 | system_resource_size = metadata.GetSystemResourceSize(); | 266 | system_resource_size = metadata.GetSystemResourceSize(); |
| 273 | image_size = code_size; | 267 | image_size = code_size; |
| 274 | 268 | ||
| 275 | // Set initial resource limits | ||
| 276 | resource_limit->SetLimitValue( | ||
| 277 | LimitableResource::PhysicalMemory, | ||
| 278 | kernel.MemoryManager().GetSize(KMemoryManager::Pool::Application)); | ||
| 279 | KScopedResourceReservation memory_reservation(resource_limit, LimitableResource::PhysicalMemory, | 269 | KScopedResourceReservation memory_reservation(resource_limit, LimitableResource::PhysicalMemory, |
| 280 | code_size + system_resource_size); | 270 | code_size + system_resource_size); |
| 281 | if (!memory_reservation.Succeeded()) { | 271 | if (!memory_reservation.Succeeded()) { |
| @@ -324,16 +314,6 @@ ResultCode Process::LoadFromMetadata(const FileSys::ProgramMetadata& metadata, | |||
| 324 | UNREACHABLE(); | 314 | UNREACHABLE(); |
| 325 | } | 315 | } |
| 326 | 316 | ||
| 327 | // Set initial resource limits | ||
| 328 | resource_limit->SetLimitValue( | ||
| 329 | LimitableResource::PhysicalMemory, | ||
| 330 | kernel.MemoryManager().GetSize(KMemoryManager::Pool::Application)); | ||
| 331 | |||
| 332 | resource_limit->SetLimitValue(LimitableResource::Threads, 608); | ||
| 333 | resource_limit->SetLimitValue(LimitableResource::Events, 700); | ||
| 334 | resource_limit->SetLimitValue(LimitableResource::TransferMemory, 128); | ||
| 335 | resource_limit->SetLimitValue(LimitableResource::Sessions, 894); | ||
| 336 | |||
| 337 | // Create TLS region | 317 | // Create TLS region |
| 338 | tls_region_address = CreateTLSRegion(); | 318 | tls_region_address = CreateTLSRegion(); |
| 339 | memory_reservation.Commit(); | 319 | memory_reservation.Commit(); |