From 22e5216d48793b9d34001960e55e4f633c47d8a1 Mon Sep 17 00:00:00 2001 From: Gliniak Date: Mon, 23 Dec 2024 18:55:49 +0100 Subject: [PATCH] [Threading] Change behaviour when provided timeout is 0 for Normal priority or less threads --- src/xenia/kernel/xthread.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/xenia/kernel/xthread.cc b/src/xenia/kernel/xthread.cc index 9879e4126d..c01790a33c 100644 --- a/src/xenia/kernel/xthread.cc +++ b/src/xenia/kernel/xthread.cc @@ -763,6 +763,12 @@ X_STATUS XThread::Delay(uint32_t processor_mode, uint32_t alertable, timeout_ms = uint32_t(-timeout_ticks / 10000); // Ticks -> MS } else { timeout_ms = 0; + // TODO(Gliniak): Check how it works, but it seems outright wrong. + // However some titles like to change priority then go to sleep with timeout + // 0. + if (priority_ <= xe::threading::ThreadPriority::kNormal) { + timeout_ms = 1; + } } timeout_ms = Clock::ScaleGuestDurationMillis(timeout_ms); if (alertable) {