From b72cfaa909a77129226adbde585f6b7a6db58c37 Mon Sep 17 00:00:00 2001 From: ergo720 <45463469+ergo720@users.noreply.github.com> Date: Sun, 12 Mar 2023 11:20:39 +0100 Subject: [PATCH] Account for delays between calls to KiClockIsr This fixes the slowness in the dashboard --- src/common/Timer.cpp | 2 +- src/core/kernel/exports/EmuKrnlKi.cpp | 8 ++++---- src/core/kernel/exports/EmuKrnlKi.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common/Timer.cpp b/src/common/Timer.cpp index 983b85d7d..830459de9 100644 --- a/src/common/Timer.cpp +++ b/src/common/Timer.cpp @@ -103,7 +103,7 @@ static uint64_t pit_next(uint64_t now) uint64_t next = pit_last + pit_period; if (now >= next) { - xbox::KiClockIsr(); + xbox::KiClockIsr((now - pit_last - pit_period) / 1000); pit_last = get_now(); return pit_period; } diff --git a/src/core/kernel/exports/EmuKrnlKi.cpp b/src/core/kernel/exports/EmuKrnlKi.cpp index 5dd308383..8680815bf 100644 --- a/src/core/kernel/exports/EmuKrnlKi.cpp +++ b/src/core/kernel/exports/EmuKrnlKi.cpp @@ -145,7 +145,7 @@ xbox::void_xt xbox::KiWaitListUnlock() KiWaitListMtx.Mtx.unlock(); } -xbox::void_xt xbox::KiClockIsr() +xbox::void_xt xbox::KiClockIsr(ulonglong_xt ExtraMs) { KIRQL OldIrql; LARGE_INTEGER InterruptTime, SystemTime; @@ -157,7 +157,7 @@ xbox::void_xt xbox::KiClockIsr() // Update the interrupt time InterruptTime.u.LowPart = KeInterruptTime.LowPart; InterruptTime.u.HighPart = KeInterruptTime.High1Time; - InterruptTime.QuadPart += CLOCK_TIME_INCREMENT; + InterruptTime.QuadPart += (CLOCK_TIME_INCREMENT * (1 + ExtraMs)); KeInterruptTime.High2Time = InterruptTime.u.HighPart; KeInterruptTime.LowPart = InterruptTime.u.LowPart; KeInterruptTime.High1Time = InterruptTime.u.HighPart; @@ -165,14 +165,14 @@ xbox::void_xt xbox::KiClockIsr() // Update the system time SystemTime.u.LowPart = KeSystemTime.LowPart; SystemTime.u.HighPart = KeSystemTime.High1Time; - SystemTime.QuadPart += CLOCK_TIME_INCREMENT; + SystemTime.QuadPart += (CLOCK_TIME_INCREMENT * (1 + ExtraMs)); KeSystemTime.High2Time = SystemTime.u.HighPart; KeSystemTime.LowPart = SystemTime.u.LowPart; KeSystemTime.High1Time = SystemTime.u.HighPart; // Update the tick counter OldKeTickCount = KeTickCount; - ++KeTickCount; + KeTickCount += (1 + static_cast(ExtraMs)); // Because this function must be fast to continuously update the kernel clocks, if somebody else is currently // holding the lock, we won't wait and instead skip the check of the timers for this cycle diff --git a/src/core/kernel/exports/EmuKrnlKi.h b/src/core/kernel/exports/EmuKrnlKi.h index 0d8ec0245..868b64c1c 100644 --- a/src/core/kernel/exports/EmuKrnlKi.h +++ b/src/core/kernel/exports/EmuKrnlKi.h @@ -66,7 +66,7 @@ namespace xbox void_xt KiWaitListUnlock(); - void_xt KiClockIsr(); + void_xt KiClockIsr(ulonglong_xt ExtraMs); xbox::void_xt NTAPI KiCheckTimerTable (