From 1504a75a464f77c3c908a8eb02f3bc4ac51a40a6 Mon Sep 17 00:00:00 2001 From: ergo720 <45463469+ergo720@users.noreply.github.com> Date: Sun, 12 Mar 2023 10:52:35 +0100 Subject: [PATCH] Raise priority of system events thread --- src/common/Timer.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/Timer.cpp b/src/common/Timer.cpp index 2945fc32f..983b85d7d 100644 --- a/src/common/Timer.cpp +++ b/src/common/Timer.cpp @@ -158,6 +158,10 @@ static uint64_t get_next(uint64_t now) xbox::void_xt NTAPI system_events(xbox::PVOID arg) { + // Testing shows that, if this thread has the same priority of the other xbox threads, it can take tens, even hundreds of ms to complete a single loop. + // So we increase its priority to above normal, so that it completes a loop roughly every 3.1ms + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); + while (true) { const uint64_t nearest_next = get_next(get_now()); QueryPerformanceCounter(reinterpret_cast(&last_time));