qemu-devel@nongnu.org; Gonglei (Arei)
> Subject: Re: [RFC 2/2] sem-posix: use monotonic clock instead
>
> On 2/21/22 10:56, Longpeng(Mike) via wrote:
> > +long now_nsec;
> > +#ifdef CONFIG_PTHREAD_CONDATTR_SETCLOCK
> > +struct timespec now;
> > +clock_get
On 2/21/22 10:56, Longpeng(Mike) via wrote:
+long now_nsec;
+#ifdef CONFIG_PTHREAD_CONDATTR_SETCLOCK
+struct timespec now;
+clock_gettime(CLOCK_MONOTONIC, );
+now_sec = now.tv_sec;
+now_nsec = now.tv_nsec;
+#else
struct timeval tv;
gettimeofday(, NULL);
-
Use CLOCK_MONOTONIC, so the timeout isn't affected by changes
to the system time. It depends on the pthread_condattr_setclock(),
while some systems(e.g. mac os) do not support it, the behavior
won't change in these systems.
Signed-off-by: Longpeng(Mike)
---
include/qemu/thread-posix.h | 1 +