[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [patch 1/7] qemu: mutex/thread/cond wrappers
From: |
Marcelo Tosatti |
Subject: |
Re: [Qemu-devel] [patch 1/7] qemu: mutex/thread/cond wrappers |
Date: |
Mon, 23 Mar 2009 20:17:56 -0300 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
On Thu, Mar 19, 2009 at 05:59:37PM +0200, Avi Kivity wrote:
>> +static void add_to_timespec(struct timespec *ts, unsigned int msecs)
>> +{
>> + ts->tv_sec = ts->tv_sec + (long)(msecs / 1000);
>> + ts->tv_nsec = (ts->tv_nsec + ((long)msecs % 1000) * 1000000);
>> + if (ts->tv_nsec >= 1000000000) {
>> + ts->tv_nsec -= 1000000000;
>> + ts->tv_sec++;
>> + }
>> +}
>>
>
> timespec_add_msec()?
> and why milliseconds?
Well, its suitable for the current purposes. Any other suggestion?
> Also, maybe uint64_t is a better type.
>> +
>> +int qemu_mutex_timedlock(QemuMutex *mutex, unsigned int msecs)
>> +{
>> + struct timespec ts;
>> +
>> + clock_gettime(CLOCK_REALTIME, &ts);
>> + add_to_timespec(&ts, msecs);
>> +
>> + return pthread_mutex_timedlock(&mutex->lock, &ts);
>> +}
>>
>
> I would have preferred a deadline instead of a timeout, but we'll see on
> the next patches.
Please expand?
Fixed the other comments, thanks.
- [Qemu-devel] [patch 0/7] separate thread for io v2, mtosatti, 2009/03/19
- [Qemu-devel] [patch 2/7] qemu: separate thread for io, mtosatti, 2009/03/19
- [Qemu-devel] Re: [patch 2/7] qemu: separate thread for io, Anthony Liguori, 2009/03/20
- [Qemu-devel] Re: [patch 2/7] qemu: separate thread for io, Marcelo Tosatti, 2009/03/20
- [Qemu-devel] Re: [patch 2/7] qemu: separate thread for io, Anthony Liguori, 2009/03/20
- [Qemu-devel] Re: [patch 2/7] qemu: separate thread for io, Marcelo Tosatti, 2009/03/20
- [Qemu-devel] Re: [patch 2/7] qemu: separate thread for io, Anthony Liguori, 2009/03/20
- [Qemu-devel] Re: [patch 2/7] qemu: separate thread for io, Avi Kivity, 2009/03/22
- [Qemu-devel] Re: [patch 2/7] qemu: separate thread for io, Anthony Liguori, 2009/03/22
[Qemu-devel] [patch 3/7] qemu: main thread does io and cpu thread is spawned, mtosatti, 2009/03/19