mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-12-23 17:00:57 +01:00
Move to GetGlobalTimeNs, fix GetTotalPhysicalMemoryAvailable
This commit is contained in:
parent
3be1a565f8
commit
3bf62c7a8a
3 changed files with 7 additions and 9 deletions
|
@ -14,8 +14,7 @@
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
namespace {
|
namespace {
|
||||||
static const s64 DefaultTimeout =
|
constexpr s64 DefaultTimeout = 10000000000; // 10 seconds
|
||||||
Core::Timing::msToCycles(std::chrono::milliseconds{10000}); // 10 seconds
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KResourceLimit::KResourceLimit(KernelCore& kernel, Core::System& system)
|
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) {
|
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) {
|
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] &&
|
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++;
|
waiter_count++;
|
||||||
cond_var.Wait(&m_lock, timeout);
|
cond_var.Wait(&m_lock, timeout);
|
||||||
waiter_count--;
|
waiter_count--;
|
||||||
|
|
|
@ -154,7 +154,7 @@ void Process::DecrementThreadCount() {
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 Process::GetTotalPhysicalMemoryAvailable() const {
|
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 +
|
page_table->GetTotalHeapSize() + GetSystemResourceSize() + image_size +
|
||||||
main_thread_stack_size};
|
main_thread_stack_size};
|
||||||
|
|
||||||
|
|
|
@ -1451,10 +1451,9 @@ static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr e
|
||||||
Svc::ResultInvalidPriority);
|
Svc::ResultInvalidPriority);
|
||||||
R_UNLESS(process.CheckThreadPriority(priority), Svc::ResultInvalidPriority);
|
R_UNLESS(process.CheckThreadPriority(priority), Svc::ResultInvalidPriority);
|
||||||
|
|
||||||
ASSERT(process.GetResourceLimit()->Reserve(
|
ASSERT(process.GetResourceLimit()->Reserve(LimitableResource::ThreadCountMax, 1,
|
||||||
LimitableResource::ThreadCountMax, 1,
|
system.CoreTiming().GetGlobalTimeNs().count() +
|
||||||
system.CoreTiming().GetClockTicks() +
|
100000000));
|
||||||
Core::Timing::msToCycles(std::chrono::milliseconds{100})));
|
|
||||||
|
|
||||||
std::shared_ptr<KThread> thread;
|
std::shared_ptr<KThread> thread;
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue