[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 01/10] Introduce qemu_cond_timedwait for POSI
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH v3 01/10] Introduce qemu_cond_timedwait for POSIX |
Date: |
Thu, 5 Apr 2012 12:19:33 +0100 |
On 5 April 2012 11:59, Jan Kiszka <address@hidden> wrote:
> +/* Returns true if condition was signals, false if timed out. */
> +bool qemu_cond_timedwait(QemuCond *cond, QemuMutex *mutex,
> + unsigned int timeout_ms)
> +{
> + struct timespec ts;
> + struct timeval tv;
> + int err;
> +
> + gettimeofday(&tv, NULL);
> + ts.tv_sec = tv.tv_sec + timeout_ms / 1000;
> + ts.tv_nsec = tv.tv_usec * 1000 + timeout_ms % 1000;
> + if (ts.tv_nsec > 1000000000) {
> + ts.tv_sec++;
> + ts.tv_nsec -= 1000000000;
> + }
> + err = pthread_cond_timedwait(&cond->cond, &mutex->lock, &ts);
Use clock_gettime() and avoid the need to convert a struct timeval
to a struct timespec ?
-- PMM
- [Qemu-devel] [PATCH v3 00/10] Use more central threading and synchronization services, Jan Kiszka, 2012/04/05
- [Qemu-devel] [PATCH v3 01/10] Introduce qemu_cond_timedwait for POSIX, Jan Kiszka, 2012/04/05
- Re: [Qemu-devel] [PATCH v3 01/10] Introduce qemu_cond_timedwait for POSIX,
Peter Maydell <=
- Re: [Qemu-devel] [PATCH v3 01/10] Introduce qemu_cond_timedwait for POSIX, Jan Kiszka, 2012/04/05
- Re: [Qemu-devel] [PATCH v3 01/10] Introduce qemu_cond_timedwait for POSIX, Peter Maydell, 2012/04/05
- Re: [Qemu-devel] [PATCH v3 01/10] Introduce qemu_cond_timedwait for POSIX, malc, 2012/04/05
- Re: [Qemu-devel] [PATCH v3 01/10] Introduce qemu_cond_timedwait for POSIX, Paolo Bonzini, 2012/04/05
- Re: [Qemu-devel] [PATCH v3 01/10] Introduce qemu_cond_timedwait for POSIX, malc, 2012/04/05
- Re: [Qemu-devel] [PATCH v3 01/10] Introduce qemu_cond_timedwait for POSIX, Paolo Bonzini, 2012/04/05
- Re: [Qemu-devel] [PATCH v3 01/10] Introduce qemu_cond_timedwait for POSIX, Jan Kiszka, 2012/04/05
- Re: [Qemu-devel] [PATCH v3 01/10] Introduce qemu_cond_timedwait for POSIX, malc, 2012/04/05
- Re: [Qemu-devel] [PATCH v3 01/10] Introduce qemu_cond_timedwait for POSIX, Jan Kiszka, 2012/04/05
- Re: [Qemu-devel] [PATCH v3 01/10] Introduce qemu_cond_timedwait for POSIX, malc, 2012/04/05