mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-23 11:39:53 +00:00
util/qemu-timer: Busy-wait in poll to prioritize timer deadlines
This commit is contained in:
parent
48c1720da8
commit
1336c6a0ff
@ -347,6 +347,22 @@ int qemu_poll_ns(GPollFD *fds, guint nfds, int64_t timeout)
|
||||
return ppoll((struct pollfd *)fds, nfds, &ts, NULL);
|
||||
}
|
||||
#else
|
||||
|
||||
#ifdef XBOX
|
||||
/* Timers are facilitated by this function. Busy-wait if the deadline is
|
||||
* near, to avoid missing deadlines due to costly sleeps.
|
||||
*/
|
||||
#define XBOX_BUSYWAIT_THRESHOLD_NS 1250000
|
||||
if ((0 < timeout) && (timeout < XBOX_BUSYWAIT_THRESHOLD_NS)) {
|
||||
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
|
||||
int64_t end = now + timeout;
|
||||
while (now < end) {
|
||||
now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
|
||||
}
|
||||
timeout = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
return g_poll(fds, nfds, qemu_timeout_ns_to_ms(timeout));
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user