diff options
author | Chloe Marcec <dmarcecguzman@gmail.com> | 2021-01-30 11:03:10 +0100 |
---|---|---|
committer | Chloe Marcec <dmarcecguzman@gmail.com> | 2021-01-30 11:03:10 +0100 |
commit | 3bf62c7a8a68822e608c2f5f5748bd111d7ee4cf (patch) | |
tree | 216d2ee14432256f4c29f4ee656499eb936ff514 /src/core/hle/kernel | |
parent | kernel: Rewrite resource limit to be more accurate (diff) | |
download | yuzu-3bf62c7a8a68822e608c2f5f5748bd111d7ee4cf.tar yuzu-3bf62c7a8a68822e608c2f5f5748bd111d7ee4cf.tar.gz yuzu-3bf62c7a8a68822e608c2f5f5748bd111d7ee4cf.tar.bz2 yuzu-3bf62c7a8a68822e608c2f5f5748bd111d7ee4cf.tar.lz yuzu-3bf62c7a8a68822e608c2f5f5748bd111d7ee4cf.tar.xz yuzu-3bf62c7a8a68822e608c2f5f5748bd111d7ee4cf.tar.zst yuzu-3bf62c7a8a68822e608c2f5f5748bd111d7ee4cf.zip |
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r-- | src/core/hle/kernel/k_resource_limit.cpp | 7 | ||||
-rw-r--r-- | src/core/hle/kernel/process.cpp | 2 | ||||
-rw-r--r-- | src/core/hle/kernel/svc.cpp | 7 |
3 files changed, 7 insertions, 9 deletions
diff --git a/src/core/hle/kernel/k_resource_limit.cpp b/src/core/hle/kernel/k_resource_limit.cpp index f943d6562..b3076b030 100644 --- a/src/core/hle/kernel/k_resource_limit.cpp +++ b/src/core/hle/kernel/k_resource_limit.cpp @@ -14,8 +14,7 @@ namespace Kernel { namespace { -static const s64 DefaultTimeout = - Core::Timing::msToCycles(std::chrono::milliseconds{10000}); // 10 seconds +constexpr s64 DefaultTimeout = 10000000000; // 10 seconds } KResourceLimit::KResourceLimit(KernelCore& kernel, Core::System& system) @@ -86,7 +85,7 @@ ResultCode KResourceLimit::SetLimitValue(LimitableResource which, s64 value) { } bool KResourceLimit::Reserve(LimitableResource which, s64 value) { - return Reserve(which, value, system.CoreTiming().GetClockTicks() + DefaultTimeout); + return Reserve(which, value, system.CoreTiming().GetGlobalTimeNs().count() + DefaultTimeout); } bool KResourceLimit::Reserve(LimitableResource which, s64 value, s64 timeout) { @@ -117,7 +116,7 @@ bool KResourceLimit::Reserve(LimitableResource which, s64 value, s64 timeout) { } if (current_hints[index] + value <= limit_values[index] && - (timeout < 0 || system.CoreTiming().GetClockTicks() < static_cast<u64>(timeout))) { + (timeout < 0 || system.CoreTiming().GetGlobalTimeNs().count() < timeout)) { waiter_count++; cond_var.Wait(&m_lock, timeout); waiter_count--; diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 6b63a32c5..9efcb95f3 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp @@ -154,7 +154,7 @@ void Process::DecrementThreadCount() { } u64 Process::GetTotalPhysicalMemoryAvailable() const { - const u64 capacity{resource_limit->GetCurrentValue(LimitableResource::PhysicalMemoryMax) + + const u64 capacity{resource_limit->GetFreeValue(LimitableResource::PhysicalMemoryMax) + page_table->GetTotalHeapSize() + GetSystemResourceSize() + image_size + main_thread_stack_size}; diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 4bae37d10..d89873104 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -1451,10 +1451,9 @@ static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr e Svc::ResultInvalidPriority); R_UNLESS(process.CheckThreadPriority(priority), Svc::ResultInvalidPriority); - ASSERT(process.GetResourceLimit()->Reserve( - LimitableResource::ThreadCountMax, 1, - system.CoreTiming().GetClockTicks() + - Core::Timing::msToCycles(std::chrono::milliseconds{100}))); + ASSERT(process.GetResourceLimit()->Reserve(LimitableResource::ThreadCountMax, 1, + system.CoreTiming().GetGlobalTimeNs().count() + + 100000000)); std::shared_ptr<KThread> thread; { |