diff options
| author | 2021-01-30 21:03:10 +1100 | |
|---|---|---|
| committer | 2021-01-30 21:03:10 +1100 | |
| commit | 3bf62c7a8a68822e608c2f5f5748bd111d7ee4cf (patch) | |
| tree | 216d2ee14432256f4c29f4ee656499eb936ff514 /src | |
| parent | kernel: Rewrite resource limit to be more accurate (diff) | |
| download | yuzu-3bf62c7a8a68822e608c2f5f5748bd111d7ee4cf.tar.gz yuzu-3bf62c7a8a68822e608c2f5f5748bd111d7ee4cf.tar.xz yuzu-3bf62c7a8a68822e608c2f5f5748bd111d7ee4cf.zip | |
Move to GetGlobalTimeNs, fix GetTotalPhysicalMemoryAvailable
Diffstat (limited to 'src')
| -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 @@ | |||
| 14 | 14 | ||
| 15 | namespace Kernel { | 15 | namespace Kernel { |
| 16 | namespace { | 16 | namespace { |
| 17 | static const s64 DefaultTimeout = | 17 | constexpr s64 DefaultTimeout = 10000000000; // 10 seconds |
| 18 | Core::Timing::msToCycles(std::chrono::milliseconds{10000}); // 10 seconds | ||
| 19 | } | 18 | } |
| 20 | 19 | ||
| 21 | KResourceLimit::KResourceLimit(KernelCore& kernel, Core::System& system) | 20 | KResourceLimit::KResourceLimit(KernelCore& kernel, Core::System& system) |
| @@ -86,7 +85,7 @@ ResultCode KResourceLimit::SetLimitValue(LimitableResource which, s64 value) { | |||
| 86 | } | 85 | } |
| 87 | 86 | ||
| 88 | bool KResourceLimit::Reserve(LimitableResource which, s64 value) { | 87 | bool KResourceLimit::Reserve(LimitableResource which, s64 value) { |
| 89 | return Reserve(which, value, system.CoreTiming().GetClockTicks() + DefaultTimeout); | 88 | return Reserve(which, value, system.CoreTiming().GetGlobalTimeNs().count() + DefaultTimeout); |
| 90 | } | 89 | } |
| 91 | 90 | ||
| 92 | bool KResourceLimit::Reserve(LimitableResource which, s64 value, s64 timeout) { | 91 | bool KResourceLimit::Reserve(LimitableResource which, s64 value, s64 timeout) { |
| @@ -117,7 +116,7 @@ bool KResourceLimit::Reserve(LimitableResource which, s64 value, s64 timeout) { | |||
| 117 | } | 116 | } |
| 118 | 117 | ||
| 119 | if (current_hints[index] + value <= limit_values[index] && | 118 | if (current_hints[index] + value <= limit_values[index] && |
| 120 | (timeout < 0 || system.CoreTiming().GetClockTicks() < static_cast<u64>(timeout))) { | 119 | (timeout < 0 || system.CoreTiming().GetGlobalTimeNs().count() < timeout)) { |
| 121 | waiter_count++; | 120 | waiter_count++; |
| 122 | cond_var.Wait(&m_lock, timeout); | 121 | cond_var.Wait(&m_lock, timeout); |
| 123 | waiter_count--; | 122 | 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() { | |||
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | u64 Process::GetTotalPhysicalMemoryAvailable() const { | 156 | u64 Process::GetTotalPhysicalMemoryAvailable() const { |
| 157 | const u64 capacity{resource_limit->GetCurrentValue(LimitableResource::PhysicalMemoryMax) + | 157 | const u64 capacity{resource_limit->GetFreeValue(LimitableResource::PhysicalMemoryMax) + |
| 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 | ||
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 | |||
| 1451 | Svc::ResultInvalidPriority); | 1451 | Svc::ResultInvalidPriority); |
| 1452 | R_UNLESS(process.CheckThreadPriority(priority), Svc::ResultInvalidPriority); | 1452 | R_UNLESS(process.CheckThreadPriority(priority), Svc::ResultInvalidPriority); |
| 1453 | 1453 | ||
| 1454 | ASSERT(process.GetResourceLimit()->Reserve( | 1454 | ASSERT(process.GetResourceLimit()->Reserve(LimitableResource::ThreadCountMax, 1, |
| 1455 | LimitableResource::ThreadCountMax, 1, | 1455 | system.CoreTiming().GetGlobalTimeNs().count() + |
| 1456 | system.CoreTiming().GetClockTicks() + | 1456 | 100000000)); |
| 1457 | Core::Timing::msToCycles(std::chrono::milliseconds{100}))); | ||
| 1458 | 1457 | ||
| 1459 | std::shared_ptr<KThread> thread; | 1458 | std::shared_ptr<KThread> thread; |
| 1460 | { | 1459 | { |