|
From: | Paolo Bonzini |
Subject: | [Qemu-devel] Re: [PATCH] Autodetect clock_gettime |
Date: | Tue, 15 Mar 2011 14:58:55 +0100 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7 |
On 03/15/2011 02:47 PM, Tristan Gingold wrote:
On Mar 15, 2011, at 2:34 PM, Paolo Bonzini wrote:On 03/15/2011 02:16 PM, Tristan Gingold wrote:Some POSIX OSes (such as Darwin) doesn't have clock_gettime. This patch falls back on gettimeofday if clock_gettime is not available.This may be okay as a stopgap measure, but any sane porting target for QEMU should have a monotonic clock. In fact, Darwin has it.Yes mach primitives could be used. But why isn't a monotonic clock used on Linux ? According to man, CLOCK_MONOTONIC is monotonic while CLOCK_REALTIME isn't.
/me rereads the patchUnfortunately, pthread timed wait/lock functions are documented to use the realtime clock by default. Using pthread_condattr_setclock is probably not portable enough, and anyway there is no such function for mutexes so we're stuck with CLOCK_REALTIME. What you're patching is fine, but those functions might actually go away soon as they're not supported on Win32.
So, in addition to what you've done, you should probably use those Mach primitives in qemu-timer.h.
Paolo
[Prev in Thread] | Current Thread | [Next in Thread] |